diff --git a/test/known_issues/known_issues.status b/test/known_issues/known_issues.status index d7e0b546d43ff8..8da183080382f5 100644 --- a/test/known_issues/known_issues.status +++ b/test/known_issues/known_issues.status @@ -5,6 +5,7 @@ prefix known_issues # sample-test : SKIP [true] # This section applies to all platforms +test-repl-uncaught-exception-error: SKIP [$system==win32] test-fs-copyfile-respect-permissions: SKIP diff --git a/test/known_issues/test-repl-uncaught-exception-error.js b/test/known_issues/test-repl-uncaught-exception-error.js new file mode 100644 index 00000000000000..d496e156640df5 --- /dev/null +++ b/test/known_issues/test-repl-uncaught-exception-error.js @@ -0,0 +1,39 @@ +'use strict'; + +require('../common'); +const ArrayStream = require('../common/arraystream'); +const repl = require('repl'); + +// Adding an `uncaughtException` listener in an REPL instance suppresses errors +// in the whole application. +// Closing the instance won't remove those listeners either. + +let accum = ''; + +const output = new ArrayStream(); +output.write = (data) => accum += data.replace('\r', ''); + +const r = repl.start({ + prompt: '', + input: new ArrayStream(), + output, + terminal: false, + useColors: false, + global: false +}); + +r.write( + 'setTimeout(() => {\n' + + ' process.on("uncaughtException", () => console.log("Foo"));\n' + + '}, 1);\n' +); + +// Event listeners added to the global `process` won't be removed after +// closing the REPL instance! Those should be removed again, especially since +// the REPL's `global` option is set to `false`. +r.close(); + +setTimeout(() => { + // This should definitely not be silenced! + throw new Error('HU'); +}, 2);