diff options
author | Bryan English <bryan@bryanenglish.com> | 2021-05-25 23:52:45 -0400 |
---|---|---|
committer | Bryan English <bryan@bryanenglish.com> | 2021-06-02 10:56:29 -0400 |
commit | a172397237af2dbc0c28af45f9edf067c9df544f (patch) | |
tree | 7386305ee0b679da598e088555190777a7a3fa47 /src/node_contextify.cc | |
parent | 3ec7f300c1633d0cbf081e0366858d373e008fdc (diff) | |
download | node-new-a172397237af2dbc0c28af45f9edf067c9df544f.tar.gz |
src: set PromiseHooks by Environment
The new JS PromiseHooks introduced in the referenced PR are per
v8::Context. This meant that code depending on them, such as
AsyncLocalStorage, wouldn't behave correctly across vm.Context
instances.
PromiseHooks are now synchronized across the main Context and any
Context created via vm.Context.
Refs: https://github.com/nodejs/node/pull/36394
Fixes: https://github.com/nodejs/node/issues/38781
Signed-off-by: Bryan English <bryan@bryanenglish.com>
PR-URL: https://github.com/nodejs/node/pull/38821
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_contextify.cc')
-rw-r--r-- | src/node_contextify.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 984569ea6b..ae5fc2fbf1 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -127,6 +127,11 @@ ContextifyContext::ContextifyContext( ContextifyContext::~ContextifyContext() { env()->RemoveCleanupHook(CleanupHook, this); + Isolate* isolate = env()->isolate(); + HandleScope scope(isolate); + + env()->async_hooks() + ->RemoveContext(PersistentToLocal::Weak(isolate, context_)); } |