GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: preserve h2 queue on out-of-order completion by mcollina · Pull Request #5410 · nodejs/undici

Conversation

@mcollina

@mcollina mcollina commented Jun 10, 2026

Copy link
Copy Markdown
Member

Fixes: #5404

HTTP/2 streams can complete out of order. The H2 completion path was advancing kRunningIdx and clearing kQueue[kRunningIdx], which assumes in-order completion. When a later stream completed first, this could clear the wrong request slot and leave completed/running entries misclassified. Destroy/error paths could then lose the still-running request or encounter null queue entries.

This changes H2 request finalization to remove the actual completed request from the running queue section, preserving other running requests. It also skips stale null entries defensively in destroy/error cleanup loops.

Tested with:

  • node --test test/issue-5404.js
  • node --test test/issue-5404.js test/http2-resume-null-request.js test/http2-goaway-retry-body.js test/http2-invalid-session.js
  • node --test test/http2-dispatcher.js
  • node --test test/issue-5404.js test/http2-pipelining-default.js
  • npm run test:h2:core
  • npm run lint

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mcollina
mcollina requested review from metcoder95 and trivikr and removed request for metcoder95 June 10, 2026 13:13
@codecov-commenter

codecov-commenter commented Jun 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.23%. Comparing base (27586ee) to head (04b4b68).

Files with missing lines Patch % Lines
lib/dispatcher/client-h2.js 73.68% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5410      +/-   ##
==========================================
- Coverage   93.24%   93.23%   -0.01%     
==========================================
  Files         110      110              
  Lines       36825    36842      +17     
==========================================
+ Hits        34336    34351      +15     
- Misses       2489     2491       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the fix-h2-destroy-out-of-order-queue branch from 764c392 to 565bbd7 Compare June 10, 2026 20:32
@mcollina
fix: preserve h2 queue on out-of-order completion
04b4b68
Signed-off-by: Matteo Collina <[email protected]>
@mcollina
mcollina force-pushed the fix-h2-destroy-out-of-order-queue branch from 565bbd7 to 04b4b68 Compare June 11, 2026 07:53
metcoder95
metcoder95 approved these changes Jun 11, 2026
View reviewed changes
@mcollina
mcollina merged commit 6df53c5 into main Jun 13, 2026
38 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina deleted the fix-h2-destroy-out-of-order-queue branch June 13, 2026 10:04
@github-actions github-actions Bot mentioned this pull request Jun 15, 2026
[Release] v8.5.0 #5429
Merged
@ronag ronag mentioned this pull request Jul 1, 2026
Sync high-value upstream fixes: response queue poisoning (GHSA-35p6-xmwp-9g52), multi-byte setEncoding, null queue guard nxtedition/undici#5
Merged
@mcollina mcollina mentioned this pull request Jul 29, 2026
fix(h2): retire the request that completed, not the head of the queue #5618
Merged
mcollina added a commit that referenced this pull request Jul 30, 2026
@mcollina @claude
fix(h2): retire the request that completed, not the head of the queue (…
4d7bf6b
…#5618)

Backport of #5410 (and the fast path from #5569).

HTTP/2 completes out of order, but every completion site advanced the
running index blindly:

    client[kQueue][client[kRunningIdx]++] = null

so whichever request happened to sit at the head was retired instead of the
one that actually finished. With two streams in flight, completing the
second one clears the first's slot while the second stays in the running
window for good:

    after /second   queue=[null, "/second"]  runningIdx=1 pendingIdx=2
    after /third    queue=[null, null, "/third"]  runningIdx=2 pendingIdx=3

The still-running /first is gone from the queue and two finished requests
are counted as running forever, so kRunning never returns to zero. Since
_resume() stops dispatching once kRunning reaches the concurrency limit, a
client accumulating these eventually stops sending anything.

Port completeRequest() from main: retire the request by identity, keeping
the O(1) in-order fast path, and splice it out when it finished out of
order. Cleared slots can now appear in the queue, so the paths that walk it
skip them, as they do on main.

Refs: #5404
Refs: #5410
Refs: #5569


Claude-Session: https://claude.ai/code/session_01A49JamgF2TkZHu5h58ChUM

Signed-off-by: Matteo Collina <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@pranaygp pranaygp mentioned this pull request Sep 28, 2026
fix(world-vercel): keep large event bodies off busy HTTP/2 connections vercel/workflow#4458
Merged
pranaygp added a commit to vercel/workflow that referenced this pull request Sep 28, 2026
@pranaygp @claude
fix(world-vercel): keep large event bodies off busy HTTP/2 connections (
35bc428
#4458)

Event POSTs with bodies over 1 MiB (run_started carrying a multi-MiB run
input, large event batches) could not be re-buffered by the H2
multiplexing interceptor, so undici held them until the connection had
zero in-flight streams and stopped its queue behind them. On busy
instances they hung until the replay budget or maxDuration ran out.

- Send those bodies over an HTTP/1.1 agent instead.
- Upgrade undici to 7.30.0, which fixes the phantom running slot a
  failed HTTP/2 stream left on its connection (nodejs/undici#5410,
  #5569) and honors headersTimeout on HTTP/2.
- Bound events requests with 60s header/body deadlines instead of
  undici's 300s defaults, which outlasted the 240s replay budget.
- Retry event-log reads (GET only) whose stream the peer reset with
  ERR_HTTP2_STREAM_ERROR.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
github-actions Bot added a commit to vercel/workflow that referenced this pull request Sep 28, 2026
@github-actions @claude
fix(world-vercel): keep large event bodies off busy HTTP/2 connections (
0310746
#4458)

Event POSTs with bodies over 1 MiB (run_started carrying a multi-MiB run
input, large event batches) could not be re-buffered by the H2
multiplexing interceptor, so undici held them until the connection had
zero in-flight streams and stopped its queue behind them. On busy
instances they hung until the replay budget or maxDuration ran out.

- Send those bodies over an HTTP/1.1 agent instead.
- Upgrade undici to 7.30.0, which fixes the phantom running slot a
  failed HTTP/2 stream left on its connection (nodejs/undici#5410,
  #5569) and honors headersTimeout on HTTP/2.
- Bound events requests with 60s header/body deadlines instead of
  undici's 300s defaults, which outlasted the 240s replay budget.
- Retry event-log reads (GET only) whose stream the peer reset with
  ERR_HTTP2_STREAM_ERROR.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Pranay Prakash <[email protected]>
pranaygp pushed a commit to vercel/workflow that referenced this pull request Sep 29, 2026
@github-actions @claude
fix(world-vercel): keep large event bodies off busy HTTP/2 connections (
42c9810
#4458) (#4461)

Event POSTs with bodies over 1 MiB (run_started carrying a multi-MiB run
input, large event batches) could not be re-buffered by the H2
multiplexing interceptor, so undici held them until the connection had
zero in-flight streams and stopped its queue behind them. On busy
instances they hung until the replay budget or maxDuration ran out.

- Send those bodies over an HTTP/1.1 agent instead.
- Upgrade undici to 7.30.0, which fixes the phantom running slot a
  failed HTTP/2 stream left on its connection (nodejs/undici#5410,
  #5569) and honors headersTimeout on HTTP/2.
- Bound events requests with 60s header/body deadlines instead of
  undici's 300s defaults, which outlasted the 240s replay budget.
- Retry event-log reads (GET only) whose stream the peer reset with
  ERR_HTTP2_STREAM_ERROR.

Signed-off-by: Pranay Prakash <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@metcoder95 metcoder95 metcoder95 approved these changes
@trivikr trivikr Awaiting requested review from trivikr

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

HTTP/2: TypeError: Cannot read properties of null (reading 'onResponseError')

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mcollina @codecov-commenter @metcoder95
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.