V8ScriptEngine usage pattern #355
-
I have a few questions about using V8ScriptEngine properly. I have an environment that will be polling a queue for script names, and then will download/cache/compile those scripts by name. My questions are:
Thanks in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello Ike,
That's safe only if the script engines share a V8 runtime. Attempting to execute a compiled script in a foreign runtime should generate an exception, although there's currently a bug that causes a crash in this situation.
If you mean that the scripts create global functions with the same names, then yes, that's safe.
Creating a new engine instance is the only way to guarantee a pristine JavaScript environment. However, instantiating Please don't hesitate to send additional questions our way. Thank you! |
Beta Was this translation helpful? Give feedback.
Hello Ike,
That's safe only if the script engines share a V8 runtime. Attempting to execute a compiled script in a foreign runtime should generate an exception, although there's currently a bug that causes a crash in this situation.
If you mean that the scripts create global functions with the same names, then yes, that's safe.
Creating a new engine instance is…