diff options
author | Michaël Zasso <targos@protonmail.com> | 2019-11-02 12:10:53 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-11-09 09:30:36 +0100 |
commit | 8bb83f4d3d29506c9153ff8e025b076531648e1d (patch) | |
tree | 465d51926e41a7745e52d808827611b45834ef49 /lib/internal/bootstrap | |
parent | 0356746f50189368172d389ea1b69d8876cf329b (diff) | |
download | android-node-v8-8bb83f4d3d29506c9153ff8e025b076531648e1d.tar.gz android-node-v8-8bb83f4d3d29506c9153ff8e025b076531648e1d.tar.bz2 android-node-v8-8bb83f4d3d29506c9153ff8e025b076531648e1d.zip |
esm: exit the process with an error if loader has an issue
Previously, this would trigger an unhandled rejection that the user
cannot handle.
Fixes: https://github.com/nodejs/node/issues/30205
PR-URL: https://github.com/nodejs/node/pull/30219
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'lib/internal/bootstrap')
-rw-r--r-- | lib/internal/bootstrap/pre_execution.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index e58293e616..39bc128bf7 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -484,16 +484,16 @@ function runMainESM(mainPath) { return esmLoader.initializeLoader().then(() => { const main = path.isAbsolute(mainPath) ? pathToFileURL(mainPath).href : mainPath; - return esmLoader.ESMLoader.import(main).catch((e) => { - if (hasUncaughtExceptionCaptureCallback()) { - process._fatalException(e); - return; - } - internalBinding('errors').triggerUncaughtException( - e, - true /* fromPromise */ - ); - }); + return esmLoader.ESMLoader.import(main); + }).catch((e) => { + if (hasUncaughtExceptionCaptureCallback()) { + process._fatalException(e); + return; + } + internalBinding('errors').triggerUncaughtException( + e, + true /* fromPromise */ + ); }); } |