Skip to content
Merged
Prev Previous commit
Next Next commit
move comment to handle_process_exit file
  • Loading branch information
MoonBall committed Jan 4, 2022
commit d7bb21fcacf9915c36eff5de283688123a4b5a84
4 changes: 4 additions & 0 deletions lib/internal/modules/esm/handle_process_exit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

// Handle a Promise from running code that potentially does Top-Level Await.
// In that case, it makes sense to set the exit code to a specific non-zero
// value if the main code never finishes running.
// The original purpose was https://github.com/nodejs/node/pull/34640
Comment thread
MoonBall marked this conversation as resolved.
Outdated
function handleProcessExit() {
process.exitCode ??= 13;
Comment thread
MoonBall marked this conversation as resolved.
}
Expand Down
3 changes: 0 additions & 3 deletions lib/internal/modules/run_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ function runMainESM(mainPath) {
}

async function handleMainPromise(promise) {
// Handle a Promise from running code that potentially does Top-Level Await.
// In that case, it makes sense to set the exit code to a specific non-zero
// value if the main code never finishes running.
process.on('exit', handleProcessExit);
try {
return await promise;
Expand Down