-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: fix domains + --abort-on-uncaught-exception #922
src: fix domains + --abort-on-uncaught-exception #922
Conversation
If run with --abort-on-uncaught-exception, V8 will abort the process whenever it does not see a JS-installed CatchClause in the stack. C++ TryCatch clauses are ignored. Domains work by setting a FatalException handler which is ignored when running in abort mode. This patch modifies MakeCallback to call its target function through a JS function that installs a CatchClause and manually calls _fatalException on error, if the process is both using domains and is in abort mode. Fixes: #836
Closing this for a second while I work out some bugs. |
Okay, I think this is in a better state now. |
if (has_abort_on_uncaught_and_domains) { | ||
Local<Value> fn = process->Get(env()->domain_abort_uncaught_exc_string()); | ||
if (fn->IsFunction()) { | ||
Local<Array> specialContext = Array::New(env()->isolate(), 2); |
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.
Minor style nit: snake_case, not camelCase.
LGTM with comments. V8 accepts mixed dashes and underscores in command line arguments while your patch accepts only one or the other but I don't think it matters much in practice. |
If run with --abort-on-uncaught-exception, V8 will abort the process whenever it does not see a JS-installed CatchClause in the stack. C++ TryCatch clauses are ignored. Domains work by setting a FatalException handler which is ignored when running in abort mode. This patch modifies MakeCallback to call its target function through a JS function that installs a CatchClause and manually calls _fatalException on error, if the process is both using domains and is in abort mode. Semver: patch PR-URL: #922 Fixes: #836 Reviewed-By: Ben Noordhuis <[email protected]>
Merged in 0af4c9e. |
@chrisdickinson could this be considered semver-minor? |
Semver-patch. |
@chrisdickinson You forgot to implement the same for |
If run with --abort-on-uncaught-exception, V8 will abort the process whenever it does not see a JS-installed CatchClause in the stack. C++ TryCatch clauses are ignored. Domains work by setting a FatalException handler which is ignored when running in abort mode.
This patch modifies MakeCallback to call its target function through a JS function that installs a CatchClause and manually calls _fatalException on error, if the process is both using domains and is in abort mode.
Fixes: #836
Some notes on this:
I am not a fan of how I've got the
ParseArgs
stuff working – specifically, theabort_on_uncaught_exc_
hangs off of the Environment object (which seems correct) but is also stored globally in a static boolean in node.cc. This is mostly out of expedience, since the environment hasn't been created yet, but I want to preserve the initial value. This feels bad, I am open to suggestions on how to make that better.This does add the overhead of one branch to all
MakeCallback
calls. I'm not sure if there's a way to get around this, though.Currently it does not respond to changes from
require('v8').setFlagsFromString
. I wanted to get a read on the approach before complicating that code.R=@trevnorris + @bnoordhuis, /cc @geek