Skip to content

Commit 1aaa6b7

Browse files
committed
test: add known issue
Adding an `uncaughtException` listener in an REPL instance suppresses errors in the whole application. Closing the instance won't remove those listeners either.
1 parent eb2d416 commit 1aaa6b7

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

test/known_issues/known_issues.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ prefix known_issues
55
# sample-test : SKIP
66

77
[true] # This section applies to all platforms
8+
test-repl-uncaught-exception-error: SKIP
89

910
[$system==win32]
1011
test-fs-copyfile-respect-permissions: SKIP
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
require('../common');
4+
const ArrayStream = require('../common/arraystream');
5+
const repl = require('repl');
6+
7+
// Adding an `uncaughtException` listener in an REPL instance suppresses errors
8+
// in the whole application.
9+
// Closing the instance won't remove those listeners either.
10+
11+
let accum = '';
12+
13+
const output = new ArrayStream();
14+
output.write = (data) => accum += data.replace('\r', '');
15+
16+
const r = repl.start({
17+
prompt: '',
18+
input: new ArrayStream(),
19+
output,
20+
terminal: false,
21+
useColors: false,
22+
global: false
23+
});
24+
25+
r.write(
26+
'setTimeout(() => {\n' +
27+
' process.on("uncaughtException", () => console.log("Foo"));\n' +
28+
'}, 1);\n'
29+
);
30+
31+
// Event listeners added to the global `process` won't be removed after
32+
// closing the REPL instance! Those should be removed again, especially since
33+
// the REPL's `global` option is set to `false`.
34+
r.close();
35+
36+
setTimeout(() => {
37+
// This should definitely not be silenced!
38+
throw new Error('HU');
39+
}, 2);

0 commit comments

Comments
 (0)