Skip to content

Commit

Permalink
stream: fix performance regression
Browse files Browse the repository at this point in the history
PR-URL: #39254
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
mscdex authored and ronag committed Jul 8, 2021
1 parent ce00381 commit a5ba28d
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 = true;
}
}

Expand Down

0 comments on commit a5ba28d

Please sign in to comment.