Skip to content

Commit 9b3aa51

Browse files
committed
fixup! fixup! module: handle Top-Level Await non-fulfills better
1 parent 5201960 commit 9b3aa51

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

lib/internal/modules/run_main.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,14 @@ function runMainESM(mainPath) {
4949

5050
function handleMainPromise(promise) {
5151
// Handle a Promise from running code that potentially does Top-Level Await.
52-
// In that case, it makes sense to:
53-
// - Treat a rejection as an unhandled exception
54-
// - Set the exit code to a specific non-zero value if the main code never
55-
// finishes running.
52+
// In that case, it makes sense to set the exit code to a specific non-zero
53+
// value if the main code never finishes running.
5654
function handler() {
5755
if (process.exitCode === undefined)
5856
process.exitCode = 13;
5957
}
6058
process.on('exit', handler);
61-
promise
62-
.finally(() => process.off('exit', handler))
63-
.catch((err) => {
64-
internalBinding('errors').triggerUncaughtException(
65-
err, true /* fromPromise */);
66-
});
59+
return promise.finally(() => process.off('exit', handler));
6760
}
6861

6962
// For backwards compatibility, we have to run a bunch of

0 commit comments

Comments
 (0)