perf(h1): drop idle-socket timer floor with a ref'd setImmediate - #5707
Merged
Conversation
Defer idle keep-alive validation to a ref'd setImmediate so it still runs after poll (GHSA-35p6-xmwp-9g52) without Node's setTimeout(0) timer floor or the unref'd-Immediate poll stall from #5606. Assisted by Cursor Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5707 +/- ##
=======================================
Coverage 93.47% 93.48%
=======================================
Files 110 110
Lines 38892 38900 +8
=======================================
+ Hits 36354 36365 +11
+ Misses 2538 2535 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tsctx
approved these changes
Aug 21, 2026
Member
|
Historical note: #5609 proposed the same central fix as this PR.
Strictly speaking, #5609 was not formally rejected: it received no reviews and was voluntarily closed as apparently obsolete. Its branch was also rebased after #5606, so its final displayed diff no longer clearly represents the original ref'd-Immediate proposal. Nevertheless, #5609 is the closest prior proposal and belongs in the history of this change. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This relates to...
Rationale
Sequential
fetch()/ HTTP/1.1 keep-alive reuse was paying Node'ssetTimeout(0)timer floor (~1.3–1.5ms) on every request. That dominates loopback / low-RTT workloads.#5499switched this tosetImmediateand was reverted in#5606because an unref'd Immediate lets poll block for ~500ms when the event loop is otherwise idle.Changes
setImmediateso it still runs after poll (poisoning protection) without the 1ms timer floor or the fix: revert idle socket validation to setTimeout(0) to prevent stall on idle event loop #5606 stall.fetchkeep-alive reuse stall regression test alongside the existing Pool test.benchmarks/fetch/sequential-keepalive.mjs.Features
N/A
Bug Fixes
N/A
Breaking Changes and Deprecations
N/A
Benchmarks
Re-run 2026-08-21 on Node v22.14.0 (linux x64, Intel Xeon, 4 cores). Medians of 5 runs vs
main@181c293.Sequential keep-alive
fetch().text()on loopback (connections: 1,pipelining: 1, 2000 iterations after 300 warmup):setTimeout(0))setImmediate)~7.5× faster at p50.
Status