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 {
66
66
ERR_INVALID_OPT_VALUE ,
67
67
ERR_REQUIRE_ESM
68
68
} = require ( 'internal/errors' ) . codes ;
69
+ const { hasUncaughtExceptionCaptureCallback } =
70
+ require ( 'internal/process/execution' ) ;
69
71
const { validateString } = require ( 'internal/validators' ) ;
70
72
const pendingDeprecation = getOptionValue ( '--pending-deprecation' ) ;
71
73
const experimentalExports = getOptionValue ( '--experimental-exports' ) ;
@@ -1012,6 +1014,10 @@ Module.runMain = function(main) {
1012
1014
return loader . import ( pathToFileURL ( mainPath || process . argv [ 1 ] ) . href ) ;
1013
1015
} )
1014
1016
. catch ( ( e ) => {
1017
+ if ( hasUncaughtExceptionCaptureCallback ( ) ) {
1018
+ process . _fatalException ( e ) ;
1019
+ return ;
1020
+ }
1015
1021
internalBinding ( 'errors' ) . triggerUncaughtException (
1016
1022
e ,
1017
1023
true /* fromPromise */
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ const {
99
99
} = internalBinding ( 'contextify' ) ;
100
100
101
101
const history = require ( 'internal/repl/history' ) ;
102
+ const { setImmediate } = require ( 'timers' ) ;
102
103
103
104
// Lazy-loaded.
104
105
let processTopLevelAwait ;
@@ -1074,7 +1075,11 @@ function complete(line, callback) {
1074
1075
// All this is only profitable if the nested REPL does not have a
1075
1076
// bufferedCommand.
1076
1077
if ( ! magic [ kBufferedCommandSymbol ] ) {
1077
- magic . _domain . on ( 'error' , ( err ) => { throw err ; } ) ;
1078
+ magic . _domain . on ( 'error' , ( err ) => {
1079
+ setImmediate ( ( ) => {
1080
+ throw err ;
1081
+ } ) ;
1082
+ } ) ;
1078
1083
return magic . complete ( line , callback ) ;
1079
1084
}
1080
1085
}
You can’t perform that action at this time.
0 commit comments