Skip to content

Commit 095d7d2

Browse files
committed
last tests
1 parent 10d7585 commit 095d7d2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/internal/modules/cjs/loader.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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');
6971
const { validateString } = require('internal/validators');
7072
const pendingDeprecation = getOptionValue('--pending-deprecation');
7173
const 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 */

lib/repl.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const {
9999
} = internalBinding('contextify');
100100

101101
const history = require('internal/repl/history');
102+
const { setImmediate } = require('timers');
102103

103104
// Lazy-loaded.
104105
let 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
}

0 commit comments

Comments
 (0)