-
Notifications
You must be signed in to change notification settings - Fork 7.3k
node.cc: break on uncaught exceptions #5713
Conversation
Thank you for contributing this pull request! Here are a few pointers to make sure your submission will be considered for inclusion. Commit bajtos/node@8b7cfe0 has the following error(s):
You can fix all these things without opening another issue. Please see CONTRIBUTING.md for more information |
@bnoordhuis I have submitted a first draft for review. I am not happy with duplicating Perhaps I could add a lightweight descendant of Any better idea? |
That doesn't really bother me. There are only a few TryCatch call sites (you missed one in src/node_script.cc by the way) and there should only be fewer over time. I'm not sure what the repercussions are of this change but I guess we can land it in master and try it out. Is this the final version of your PR? |
Our usual disagreement about coding style, heh? My concern is that it was already easy to miss one of the six places required to be changed, so I'd rather make sure the next person doing a similar change can avoid this risk. Anyway, you are the boss.
Yeah, I am not entirely sure either. My understanding is that this change affects only
Since
I added the missing bit in |
It's nothing This PR breaks a number of tests (see here.) The tests that break locally for me all seem to involve child processes, oddly enough. Might just be coincidence. |
Oh well. There are two additional lines printed for unhandled exception now. Apparently the verbose flag is used on other places too. E.g. for Old output:
New output:
The line-numer 1290 is weird, since timeout_throw.js has only 27 lines. |
It's V8 reporting the exception to stdout/stderr, I guess that was the original intention behind See
I am not sure what is the correct solution here.
What are your thoughts, Ben? |
Most TryCatch blocks have SetVerbose flag on, this tells V8 to report uncaught exceptions to debugger. FatalException handler is called from V8 Message listener instead from the place where TryCatch was used. Otherwise uncaught exceptions are logged twice. See comment in `deps/v8/include/v8.h` for explanation of SetVerbose flag: > By default, exceptions that are caught by an external exception > handler are not reported. Call SetVerbose with true on an > external exception handler to have exceptions caught by the > handler reported as if they were not caught. The flag is used by `Isolate::ShouldReportException()`, which is called by `Isolate::DoThrow()` to decide whether an exception is considered uncaught.
@@ -1131,7 +1127,7 @@ ssize_t DecodeWrite(char *buf, | |||
return StringBytes::Write(buf, buflen, val, encoding, NULL); | |||
} | |||
|
|||
void DisplayExceptionLine (TryCatch &try_catch) { | |||
void DisplayExceptionLine (Handle<Message> message) { |
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.
While you're here... style: no space between function name and parenthesis.
Fixed issues pointed out in the code review.
Thanks for the review, I addressed the issues in 1ebae5c. @bnoordhuis: What's your opinion on The current state is this:
Given that, is it worth the effort (and extra code) to detect such mistakes and do not log the error second time? Does it happen often that a native module adds it's own |
Landed in c16963b, thanks.
Depends on your definition of 'often'. It's not common but it's not extremely rare either.
Probably not. Let's take the reactive approach and not do anything until someone complains. |
All TryCatch blocks used in node.cc are now verbose, so that V8 debugger
can break on uncaught exceptions.
See comment in
deps/v8/include/v8.h
for explanation:The flag is used by
Isolate::ShouldReportException()
, which is calledby
Isolate::DoThrow()
to decide whether an exception is considered uncaught./cc: @bnoordhuis