File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ const {
6666 ERR_INVALID_OPT_VALUE ,
6767 ERR_REQUIRE_ESM
6868} = require ( 'internal/errors' ) . codes ;
69+ const { hasUncaughtExceptionCaptureCallback } =
70+ require ( 'internal/process/execution' ) ;
6971const { validateString } = require ( 'internal/validators' ) ;
7072const pendingDeprecation = getOptionValue ( '--pending-deprecation' ) ;
7173const experimentalExports = getOptionValue ( '--experimental-exports' ) ;
@@ -1012,6 +1014,10 @@ Module.runMain = function(main) {
10121014 return loader . import ( pathToFileURL ( mainPath || process . argv [ 1 ] ) . href ) ;
10131015 } )
10141016 . catch ( ( e ) => {
1017+ if ( hasUncaughtExceptionCaptureCallback ( ) ) {
1018+ process . _fatalException ( e ) ;
1019+ return ;
1020+ }
10151021 internalBinding ( 'errors' ) . triggerUncaughtException (
10161022 e ,
10171023 true /* fromPromise */
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ const {
9999} = internalBinding ( 'contextify' ) ;
100100
101101const history = require ( 'internal/repl/history' ) ;
102+ const { setImmediate } = require ( 'timers' ) ;
102103
103104// Lazy-loaded.
104105let processTopLevelAwait ;
@@ -1074,7 +1075,11 @@ function complete(line, callback) {
10741075 // All this is only profitable if the nested REPL does not have a
10751076 // bufferedCommand.
10761077 if ( ! magic [ kBufferedCommandSymbol ] ) {
1077- magic . _domain . on ( 'error' , ( err ) => { throw err ; } ) ;
1078+ magic . _domain . on ( 'error' , ( err ) => {
1079+ setImmediate ( ( ) => {
1080+ throw err ;
1081+ } ) ;
1082+ } ) ;
10781083 return magic . complete ( line , callback ) ;
10791084 }
10801085 }
You can’t perform that action at this time.
0 commit comments