Skip to content

fix: preserve h2 queue on out-of-order completion#5410

Open
mcollina wants to merge 1 commit into
mainfrom
fix-h2-destroy-out-of-order-queue
Open

fix: preserve h2 queue on out-of-order completion#5410
mcollina wants to merge 1 commit into
mainfrom
fix-h2-destroy-out-of-order-queue

Conversation

@mcollina

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

@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

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.

@mcollina mcollina force-pushed the fix-h2-destroy-out-of-order-queue branch from 764c392 to 565bbd7 Compare June 10, 2026 20:32
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina mcollina force-pushed the fix-h2-destroy-out-of-order-queue branch from 565bbd7 to 04b4b68 Compare June 11, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants