Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! switch to weak globals
  • Loading branch information
bengl committed May 27, 2021
commit bb559761d3690be97e01eba1c50575f812743bf1
3 changes: 2 additions & 1 deletion src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ inline void AsyncHooks::SetJSPromiseHooks(v8::Local<v8::Function> init,
js_promise_hooks_[2].Reset(env()->isolate(), after);
js_promise_hooks_[3].Reset(env()->isolate(), resolve);
for (auto it = contexts_.begin(); it != contexts_.end(); it++) {
PersistentToLocal::Strong(*it)
PersistentToLocal::Weak(env()->isolate(), *it)
->SetPromiseHooks(init, before, after, resolve);
}
}
Expand Down Expand Up @@ -249,6 +249,7 @@ inline void AsyncHooks::AddContext(v8::Local<v8::Context> ctx) {
size_t id = contexts_.size();
contexts_.resize(id + 1);
contexts_[id].Reset(env()->isolate(), ctx);
contexts_[id].SetWeak();
Comment thread
addaleax marked this conversation as resolved.
}

inline void AsyncHooks::RemoveContext(v8::Local<v8::Context> ctx) {
Expand Down
3 changes: 2 additions & 1 deletion src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ ContextifyContext::ContextifyContext(
ContextifyContext::~ContextifyContext() {
env()->RemoveCleanupHook(CleanupHook, this);

env()->async_hooks()->RemoveContext(PersistentToLocal::Strong(context_));
env()->async_hooks()
->RemoveContext(PersistentToLocal::Weak(env()->isolate(), context_));
}


Expand Down