Skip to content

Commit 4a2ba43

Browse files
lpincaMylesBorins
authored andcommitted
test: do not use the same EventEmitter instance
Prevent multiple listeners for the `'error'` event to be added to the same `EventEmitter` instance. PR-URL: #35560 Refs: #35557 (comment) Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 809cd07 commit 4a2ba43

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/parallel/test-stream2-readable-wrap-error.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ const assert = require('assert');
55
const Readable = require('_stream_readable');
66
const EE = require('events').EventEmitter;
77

8-
const oldStream = new EE();
9-
oldStream.pause = () => {};
10-
oldStream.resume = () => {};
8+
class LegacyStream extends EE {
9+
pause() {}
10+
resume() {}
11+
}
1112

1213
{
1314
const err = new Error();
15+
const oldStream = new LegacyStream();
1416
const r = new Readable({ autoDestroy: true })
1517
.wrap(oldStream)
1618
.on('error', common.mustCall(() => {
@@ -23,6 +25,7 @@ oldStream.resume = () => {};
2325

2426
{
2527
const err = new Error();
28+
const oldStream = new LegacyStream();
2629
const r = new Readable({ autoDestroy: false })
2730
.wrap(oldStream)
2831
.on('error', common.mustCall(() => {

0 commit comments

Comments
 (0)