Skip to content

Commit b4b9d5a

Browse files
authored
[test] Fix failing test when using the domain module (#2126)
Fix a failure in `test/create-websocket-stream.test.js` if the domain module is loaded (e.g. due to `NODE_OPTIONS` in environment). The cause of the failure was that installing an `'uncaughtException'` event handler on `process` causes the domain module to prepend its own handler for the same event, which confused the test. Fixes #2124
1 parent 41dc56a commit b4b9d5a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/create-websocket-stream.test.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,14 @@ describe('createWebSocketStream', () => {
295295
ws._socket.write(Buffer.from([0x85, 0x00]));
296296
});
297297

298-
assert.strictEqual(process.listenerCount('uncaughtException'), 1);
298+
assert.strictEqual(
299+
process.listenerCount('uncaughtException'),
300+
EventEmitter.usingDomains ? 2 : 1
301+
);
299302

300-
const [listener] = process.listeners('uncaughtException');
303+
const listener = process.listeners('uncaughtException').pop();
301304

302-
process.removeAllListeners('uncaughtException');
305+
process.removeListener('uncaughtException', listener);
303306
process.once('uncaughtException', (err) => {
304307
assert.ok(err instanceof Error);
305308
assert.strictEqual(

0 commit comments

Comments
 (0)