Skip to content

Commit

Permalink
stream: fix performance regression
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Jul 4, 2021
1 parent 7868062 commit 3e5aa92
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/internal/streams/duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,23 @@ function Duplex(options) {
Readable.call(this, options);
Writable.call(this, options);

this.allowHalfOpen = options?.allowHalfOpen !== false;
if (options) {
this.allowHalfOpen = options.allowHalfOpen !== false;

if (options?.readable === false) {
this._readableState.readable = false;
this._readableState.ended = true;
this._readableState.endEmitted = true;
}
if (options.readable === false) {
this._readableState.readable = false;
this._readableState.ended = true;
this._readableState.endEmitted = true;
}

if (options?.writable === false) {
this._writableState.writable = false;
this._writableState.ending = true;
this._writableState.ended = true;
this._writableState.finished = true;
if (options.writable === false) {
this._writableState.writable = false;
this._writableState.ending = true;
this._writableState.ended = true;
this._writableState.finished = true;
}
} else {
this.allowHalfOpen = false;
}
}

Expand Down

0 comments on commit 3e5aa92

Please sign in to comment.