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 <anna@addaleax.net>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • 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
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.