diff --git a/lib/internal/modules/esm/handle_process_exit.js b/lib/internal/modules/esm/handle_process_exit.js index 10b68a8b28db00..8453c7d88c6473 100644 --- a/lib/internal/modules/esm/handle_process_exit.js +++ b/lib/internal/modules/esm/handle_process_exit.js @@ -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 function handleProcessExit() { process.exitCode ??= 13; } diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js index 6cc1e0e74bc2dd..924c4836bb2aa2 100644 --- a/lib/internal/modules/run_main.js +++ b/lib/internal/modules/run_main.js @@ -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;