Skip to content

Commit

Permalink
test: do not use the same EventEmitter instance
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
lpinca authored and MylesBorins committed Oct 14, 2020
1 parent 809cd07 commit 4a2ba43
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/parallel/test-stream2-readable-wrap-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ const assert = require('assert');
const Readable = require('_stream_readable');
const EE = require('events').EventEmitter;

const oldStream = new EE();
oldStream.pause = () => {};
oldStream.resume = () => {};
class LegacyStream extends EE {
pause() {}
resume() {}
}

{
const err = new Error();
const oldStream = new LegacyStream();
const r = new Readable({ autoDestroy: true })
.wrap(oldStream)
.on('error', common.mustCall(() => {
Expand All @@ -23,6 +25,7 @@ oldStream.resume = () => {};

{
const err = new Error();
const oldStream = new LegacyStream();
const r = new Readable({ autoDestroy: false })
.wrap(oldStream)
.on('error', common.mustCall(() => {
Expand Down

0 comments on commit 4a2ba43

Please sign in to comment.