From d7bb21fcacf9915c36eff5de283688123a4b5a84 Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Tue, 4 Jan 2022 17:10:50 +0800 Subject: [PATCH] move comment to handle_process_exit file --- lib/internal/modules/esm/handle_process_exit.js | 4 ++++ lib/internal/modules/run_main.js | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) 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;