diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-06-14 18:04:13 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-06-25 03:43:29 +0300 |
commit | 0fb91acedff792463dd4f8a67c60cc645e6aa5c3 (patch) | |
tree | 6ea44b9d40aaae91eedfdda6da144df3acc2b16d /src/api | |
parent | 409fdba6d5c052f14af3ea73f0abb36db197f3d3 (diff) |
src: disallow JS execution inside FreeEnvironment
This addresses a TODO comment, and aligns the behavior between
worker threads and the main thread.
The primary motivation for this change is to more strictly enforce
the invariant that no JS runs after the `'exit'` event is emitted.
PR-URL: https://github.com/nodejs/node/pull/33874
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/environment.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/api/environment.cc b/src/api/environment.cc index a574b916fe6..210abb94295 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -27,6 +27,7 @@ using v8::Object; using v8::ObjectTemplate; using v8::Private; using v8::PropertyDescriptor; +using v8::SealHandleScope; using v8::String; using v8::Value; @@ -378,10 +379,13 @@ Environment* CreateEnvironment( } void FreeEnvironment(Environment* env) { + Isolate::DisallowJavascriptExecutionScope disallow_js(env->isolate(), + Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); { - // TODO(addaleax): This should maybe rather be in a SealHandleScope. - HandleScope handle_scope(env->isolate()); + HandleScope handle_scope(env->isolate()); // For env->context(). Context::Scope context_scope(env->context()); + SealHandleScope seal_handle_scope(env->isolate()); + env->set_stopping(true); env->stop_sub_worker_contexts(); env->RunCleanup(); |