-
Notifications
You must be signed in to change notification settings - Fork 465
Reset uncaught exception handling after startup execution #5342
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| // Reset this back to its default after startup execution | ||
| // Leaving it on comes at the expense of collecting stack traces for all thrown exceptions | ||
| if (script->isolate->impl->inspector == kj::none) { |
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.
Should we set it to false regardless of inspector? Since we use inspector for profiling as well?
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.
EDIT: Ignore comment, I misread the condition.
In the Script constructor, we do:
if (isolate->impl->inspector != kj::none || errorReporter != kj::none) {
lock.v8Isolate->SetCaptureStackTraceForUncaughtExceptions(true);
}So if the inspector is off, but errorReporter is used (which is always the case in workerd, and in dynamic isolates), then the code as currently written will leave SetCaptureStackTraceForUncaughtExceptions() on.
I think that's not what we want? Seems like we should just turn it off unconditionally here.
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.
Oops, I misread the conditional.
OK, I could go either way on this.
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.
I'll check what the behaviour's actually like in the inspector after this change (we'd still want some way of getting unhandled exceptions with the inspector on if the user wants to – just not sure if there's a way to manually turn it on via Protocol Monitor or similar)
| }); | ||
|
|
||
| // Reset this back to its default after startup execution | ||
| // Leaving it on comes at the expense of collecting stack traces for all thrown exceptions |
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 you mind adding a link to the github issue, so we don't lose the context?
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, good idea 👍
Fixes #5332
I've confirmed this keeps the stack for any uncaught errors during startup:
Turning this off any earlier (eg at the end of the Script constructor) is too early:
I've also confirmed this improves performance of running scripts with
throwpatterns as per #5332