From 9b3aa518d030736c9b7528f24e8ce8cf86512647 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 6 Aug 2020 04:33:08 +0200 Subject: [PATCH] fixup! fixup! module: handle Top-Level Await non-fulfills better --- lib/internal/modules/run_main.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js index 507d076d162b0b..d7b0ee56a1e8a5 100644 --- a/lib/internal/modules/run_main.js +++ b/lib/internal/modules/run_main.js @@ -49,21 +49,14 @@ function runMainESM(mainPath) { function handleMainPromise(promise) { // Handle a Promise from running code that potentially does Top-Level Await. - // In that case, it makes sense to: - // - Treat a rejection as an unhandled exception - // - Set the exit code to a specific non-zero value if the main code never - // finishes running. + // In that case, it makes sense to set the exit code to a specific non-zero + // value if the main code never finishes running. function handler() { if (process.exitCode === undefined) process.exitCode = 13; } process.on('exit', handler); - promise - .finally(() => process.off('exit', handler)) - .catch((err) => { - internalBinding('errors').triggerUncaughtException( - err, true /* fromPromise */); - }); + return promise.finally(() => process.off('exit', handler)); } // For backwards compatibility, we have to run a bunch of