-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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 process exit listeners not receiving unsettled tla codes #56872
base: main
Are you sure you want to change the base?
src: fix process exit listeners not receiving unsettled tla codes #56872
Conversation
fix listeners registered via `process.on('exit', ...` not receiving error code 13 when an unsettled top-level-await is encountered in the code
eef4c1f
to
80a0041
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56872 +/- ##
==========================================
- Coverage 89.16% 89.16% -0.01%
==========================================
Files 665 665
Lines 192602 192600 -2
Branches 37050 37051 +1
==========================================
- Hits 171732 171728 -4
- Misses 13678 13681 +3
+ Partials 7192 7191 -1
|
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.
Thanks for the PR. Some comments about the approaches taken.
@@ -1,2 +1,7 @@ | |||
process.on('exit', (exitCode) => { |
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.
Can you put these into separate tests? Otherwise we lose coverage of the cases where there isn't any exit handler installed.
Local<Integer> exit_code_int = | ||
Integer::New(isolate, static_cast<int32_t>(exit_code)); | ||
|
||
if (ProcessEmit(env, "exit", exit_code_int).IsEmpty()) { |
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 think prior to emitting the event, it should also set the kHasExitCode
and kExitCode
fields in the exit info buffer (basically needing an implementation of Environment::set_exit_code()
that is the counter part of Environment::exit_code
) so that in the handler, process.exitCode
would be 13, to be consistent with other paths. Also in any case, the documentation of the exit
event in doc/api/process.md
should also be updated to note this extra source of exit code.
fix listeners registered via
process.on('exit', ...
not receiving error code 13 when an unsettled top-level-await is encountered in the codeFixes: #53551