Skip to content

Commit a5ba28d

Browse files
mscdexronag
authored andcommitted
stream: fix performance regression
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]>
1 parent ce00381 commit a5ba28d

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

lib/internal/streams/duplex.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,23 @@ function Duplex(options) {
5656
Readable.call(this, options);
5757
Writable.call(this, options);
5858

59-
this.allowHalfOpen = options?.allowHalfOpen !== false;
59+
if (options) {
60+
this.allowHalfOpen = options.allowHalfOpen !== false;
6061

61-
if (options?.readable === false) {
62-
this._readableState.readable = false;
63-
this._readableState.ended = true;
64-
this._readableState.endEmitted = true;
65-
}
62+
if (options.readable === false) {
63+
this._readableState.readable = false;
64+
this._readableState.ended = true;
65+
this._readableState.endEmitted = true;
66+
}
6667

67-
if (options?.writable === false) {
68-
this._writableState.writable = false;
69-
this._writableState.ending = true;
70-
this._writableState.ended = true;
71-
this._writableState.finished = true;
68+
if (options.writable === false) {
69+
this._writableState.writable = false;
70+
this._writableState.ending = true;
71+
this._writableState.ended = true;
72+
this._writableState.finished = true;
73+
}
74+
} else {
75+
this.allowHalfOpen = true;
7276
}
7377
}
7478

0 commit comments

Comments
 (0)