-
Notifications
You must be signed in to change notification settings - Fork 15.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not defer construction by one microtick in stream (#42046)
- Loading branch information
1 parent
e76787e
commit c7187d5
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
patches/node/stream_do_not_defer_construction_by_one_microtick.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Matteo Collina <hello@matteocollina.com> | ||
Date: Thu, 7 Mar 2024 17:28:25 +0100 | ||
Subject: stream: do not defer construction by one microtick | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
||
Fixes: https://github.com/nodejs/node/issues/51993 | ||
PR-URL: https://github.com/nodejs/node/pull/52005 | ||
Reviewed-By: Robert Nagy <ronagy@icloud.com> | ||
Reviewed-By: Michaël Zasso <targos@protonmail.com> | ||
|
||
diff --git a/lib/internal/streams/destroy.js b/lib/internal/streams/destroy.js | ||
index 28802cae5eff32b17d869be5f79b28be84bc09d5..96e61491f08cfc32e1ba780b8136ec02fc38e7b9 100644 | ||
--- a/lib/internal/streams/destroy.js | ||
+++ b/lib/internal/streams/destroy.js | ||
@@ -291,7 +291,7 @@ function constructNT(stream) { | ||
} else if (err) { | ||
errorOrDestroy(stream, err, true); | ||
} else { | ||
- process.nextTick(emitConstructNT, stream); | ||
+ stream.emit(kConstruct); | ||
} | ||
} | ||
|
||
@@ -304,10 +304,6 @@ function constructNT(stream) { | ||
} | ||
} | ||
|
||
-function emitConstructNT(stream) { | ||
- stream.emit(kConstruct); | ||
-} | ||
- | ||
function isRequest(stream) { | ||
return stream?.setHeader && typeof stream.abort === 'function'; | ||
} |