Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
stream: fix performance regression
  • Loading branch information
mscdex committed Jul 4, 2021
commit a1ee30ba549331ec85cad64d21269340873405e1
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