-
Notifications
You must be signed in to change notification settings - Fork 15k
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
fix: ensure that errors thrown in the context bridge are created in the correct context #24534
Conversation
c3dc335
to
1529b62
Compare
auto ret = PassValueToOtherContext( | ||
func_owning_context, calling_context, | ||
maybe_return_value.ToLocalChecked(), &object_cache, | ||
support_dynamic_properties, 0, BridgeErrorTarget::kDestination); |
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.
Would it also be correct to use TryCatch
here to capture the error and throw a new error in the correct context? e.g.
auto ret = PassValueToOtherContext( | |
func_owning_context, calling_context, | |
maybe_return_value.ToLocalChecked(), &object_cache, | |
support_dynamic_properties, 0, BridgeErrorTarget::kDestination); | |
v8::TryCatch try_catch(isolate); | |
auto ret = PassValueToOtherContext(...); | |
if (try_catch.HasCaught()) { | |
ThrowException("Conversion of return value failed"); | |
return; | |
} |
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.
This is handled inside PassValueToOtherContext
, the way that function is written and intended to be used is that it always does everything in the right context. Any errors thrown are thrown in the correct context too so this try catch would be unnecessary.
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.
Yeah, I was just thinking about this as an alternative implementation that would be less intrusive (i.e. there would no need for this extra enum).
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.
It means we'd have to trycatch
every call to PassValueToOtherContext
which would be considerably more intrusive?
…he correct context
1529b62
to
0e4c827
Compare
No Release Notes |
I was unable to backport this PR to "7-3-x" cleanly; |
I was unable to backport this PR to "8-x-y" cleanly; |
I have automatically backported this PR to "10-x-y", please check out #24713 |
I was unable to backport this PR to "9-x-y" cleanly; |
…he correct context (#24534)
@MarshallOfSound has manually backported this PR to "9-x-y", please check out #24747 |
This PR fixes two cases where errors were being created in context A but thrown in context B.
Notes: no-notes