diff options
author | Michaël Zasso <targos@protonmail.com> | 2019-11-02 14:10:53 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-11-09 11:30:36 +0300 |
commit | 8bb83f4d3d29506c9153ff8e025b076531648e1d (patch) | |
tree | 465d51926e41a7745e52d808827611b45834ef49 /lib/internal/bootstrap | |
parent | 0356746f50189368172d389ea1b69d8876cf329b (diff) |
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 e58293e6168..39bc128bf7b 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 */ + ); }); } |