-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
process: add exitWithException() #25715
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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c0aab25 to
d7377b6
Compare
This comment has been minimized.
This comment has been minimized.
|
@Fishrock123 Yeah, I assume the question is which error should take precedence. For this API it might be the most intuitive thing to let the error from the getter bubble back up to JS land, but … that might be hard for the general case, when we might not have a JS stack below the FatalException handler? |
6fa69f9 to
5e2415c
Compare
|
So, uhhh, considering you can make node Edit: fixed in #25834 |
|
@Fishrock123 this needs a rebase |
5e2415c to
0731e05
Compare
|
Rebased and updated this to |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0731e05 to
140d36c
Compare
|
I know the name comes from existing internal methods, but TBH I think it's a bit confusing, since
If there is a scale of how fatal something is, 2 feels more "fatal" to me, since at that point there is less stuff that you are allowed to do (e.g. this happens when we use the V8 API incorrectly and there is basically nothing the user can do to recover from that) Something like |
|
Or, maybe we could make this an overload of |
|
Do people think this sort of functionality should attempt to bypass |
BridgeAR
left a comment
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 with the comments addressed.
|
@Fishrock123 I would keep it. That way it's consistent and has the same output as other errors. |
140d36c to
c403cb6
Compare
|
@joyeecheung LGTY? |
doc/api/process.md
Outdated
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.
What happens if this is uncaughtException? I think that results in a dead loop? I think we should at least document about this footgun, but maybe a better solution is to just implement this separately and exclude part of process._fatalException() - or otherwise this does not exit unconditionally any more.
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.
Hmm, throw seems to be short-cut somehow, but this blows the stack size. :/
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.
Are we even supposed to emit 'uncaughtException' when this is called? If so is there any point of using this instead of...well, just throwing an uncaught exception? I can see it makes sense to add this method if it does not trigger 'uncaughtException', but not really if it does..
Adds a public way to access `node::FatalException` from javascript, as `process.triggerFatalException()`. If an error stack is available on the value, this method of exiting does not add additional context, unlike regular re-throwing, yet also uses the regular error printing logic. This behavior is particularly desirable when doing 'fatal exits' from the unhandledRejection event. PR-URL: nodejs#25715
c403cb6 to
8546a57
Compare
|
ping @Fishrock123 |
|
The problem with this is that internals need to be suitable restructured so as to bypass emitting the Which probably also means that it need to be renamed, again... |
|
It would probably be easier to just expose the exception logger and then call |
8ae28ff to
2935f72
Compare
|
It is unfortunate that this PR stalled. To move forward, it would need to be rebased and updated and have the |
Adds a public way to access
node::FatalExceptionfrom javascript, asprocess.exitWithException().If an error stack is available on the value, this method of exiting does not add additional context, unlike regular re-throwing, yet also uses the regular error printing logic. This behavior is particularly desirable when doing 'fatal exits' from the unhandledRejection event.
... Been wanting this for some months now. 🙃
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes