-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: make cross-context MakeCallback() calls work #9221
src: make cross-context MakeCallback() calls work #9221
Conversation
return handle_scope.Escape(Local<Value>::New( | ||
isolate, | ||
MakeCallback(env, recv.As<Value>(), callback, argc, argv))); | ||
Environment* env = Environment::GetCurrent(callback->CreationContext()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callback->CreationContext()
seems a little more correct than recv->CreationContext()
because the former is the context the actual callback takes place in but it's admittedly a mostly academic difference.
@addaleax Your thoughts, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
(sorry for not reviewing sooner, as mentioned I’ll be somewhat more busy now that classes have started again)
Check that invoking a callback on a receiver from a different context works. It ran afoul of an `env->context() == isolate->GetCurrentContext()` assertion so retrieve the environment from the callback context and the context to enter from the environment's context() method. We could also have retrieved the environment from the receiver's context and that would have made little practical difference. It just seemed more correct to get it from the callback context because that is the actual execution context. PR-URL: nodejs#9221 Reviewed-By: Anna Henningsen <anna@addaleax.net>
7201c08
to
921d2b0
Compare
No problem, thanks for reviewing. |
Check that invoking a callback on a receiver from a different context works. It ran afoul of an `env->context() == isolate->GetCurrentContext()` assertion so retrieve the environment from the callback context and the context to enter from the environment's context() method. We could also have retrieved the environment from the receiver's context and that would have made little practical difference. It just seemed more correct to get it from the callback context because that is the actual execution context. PR-URL: #9221 Reviewed-By: Anna Henningsen <anna@addaleax.net>
@bnoordhuis should this be backported? |
ping @bnoordhuis |
@gibfahn I think this is good to be backported too. |
Check that invoking a callback on a receiver from a different context works. It ran afoul of an `env->context() == isolate->GetCurrentContext()` assertion so retrieve the environment from the callback context and the context to enter from the environment's context() method. We could also have retrieved the environment from the receiver's context and that would have made little practical difference. It just seemed more correct to get it from the callback context because that is the actual execution context. PR-URL: #9221 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Check that invoking a callback on a receiver from a different context works. It ran afoul of an `env->context() == isolate->GetCurrentContext()` assertion so retrieve the environment from the callback context and the context to enter from the environment's context() method. We could also have retrieved the environment from the receiver's context and that would have made little practical difference. It just seemed more correct to get it from the callback context because that is the actual execution context. PR-URL: #9221 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Check that invoking a callback on a receiver from a different context works. It ran afoul of an `env->context() == isolate->GetCurrentContext()` assertion so retrieve the environment from the callback context and the context to enter from the environment's context() method. We could also have retrieved the environment from the receiver's context and that would have made little practical difference. It just seemed more correct to get it from the callback context because that is the actual execution context. PR-URL: #9221 Reviewed-By: Anna Henningsen <anna@addaleax.net>
From #9213 (comment), cc @addaleax.
CI: https://ci.nodejs.org/job/node-test-pull-request/4607/