Skip to content

Commit

Permalink
last tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Oct 7, 2019
1 parent 10d7585 commit 095d7d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const {
ERR_INVALID_OPT_VALUE,
ERR_REQUIRE_ESM
} = require('internal/errors').codes;
const { hasUncaughtExceptionCaptureCallback } =
require('internal/process/execution');
const { validateString } = require('internal/validators');
const pendingDeprecation = getOptionValue('--pending-deprecation');
const experimentalExports = getOptionValue('--experimental-exports');
Expand Down Expand Up @@ -1012,6 +1014,10 @@ Module.runMain = function(main) {
return loader.import(pathToFileURL(mainPath || process.argv[1]).href);
})
.catch((e) => {
if (hasUncaughtExceptionCaptureCallback()) {
process._fatalException(e);
return;
}
internalBinding('errors').triggerUncaughtException(
e,
true /* fromPromise */
Expand Down
7 changes: 6 additions & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const {
} = internalBinding('contextify');

const history = require('internal/repl/history');
const { setImmediate } = require('timers');

// Lazy-loaded.
let processTopLevelAwait;
Expand Down Expand Up @@ -1074,7 +1075,11 @@ function complete(line, callback) {
// All this is only profitable if the nested REPL does not have a
// bufferedCommand.
if (!magic[kBufferedCommandSymbol]) {
magic._domain.on('error', (err) => { throw err; });
magic._domain.on('error', (err) => {
setImmediate(() => {
throw err;
});
});
return magic.complete(line, callback);
}
}
Expand Down

0 comments on commit 095d7d2

Please sign in to comment.