Skip to content

fix(agent): preserve pools with pending GOAWAY replays - #5740

Merged
mcollina merged 1 commit into
mainfrom
fix/agent-goaway-pending-pool
Aug 31, 2026
Merged

fix(agent): preserve pools with pending GOAWAY replays#5740
mcollina merged 1 commit into
mainfrom
fix/agent-goaway-pending-pool

Conversation

@mcollina

Copy link
Copy Markdown
Member

This relates to...

Spurious ClientDestroyedError disconnects can occur while using fetch() with AbortSignal.timeout() against an HTTP/2 destination that sends GOAWAY.

Rationale

When GOAWAY detaches an HTTP/2 session, refused requests are moved back to the Client's pending queue before a replacement connection is opened. During that window the owning Agent sees no connected or busy dispatcher and closes the Pool, despite the pending replays. Once those requests finish on the replacement Client, the closing Pool destroys it and emits an unexpected UND_ERR_DESTROYED disconnect.

Before this change the regression produced disconnect codes:

UND_ERR_INFO
UND_ERR_DESTROYED

The second disconnect is internal cleanup rather than a request failure.

Changes

Features

N/A

Bug Fixes

  • Keep an Agent-managed dispatcher alive while it has pending requests.
  • Add HTTP/2 regression coverage using concurrent fetch() requests, AbortSignal.timeout(3000), and a server-issued GOAWAY.
  • Assert that requeued requests complete and only the expected GOAWAY informational disconnect is emitted.

Breaking Changes and Deprecations

N/A

Status

Validation

  • npm run test:h2:core — 104 passed, 2 skipped
  • npx borp --timeout 180000 -p "test/node-test/agent.js" — 35 passed
  • npx borp --timeout 180000 -p "test/issue-4806.js" — passed
  • npx eslint lib/dispatcher/agent.js test/http2-goaway.js — passed

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollina requested review from metcoder95 and ronag August 30, 2026 19:45
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.46%. Comparing base (fc3450d) to head (a7652e7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5740      +/-   ##
==========================================
- Coverage   93.47%   93.46%   -0.01%     
==========================================
  Files         110      110              
  Lines       38908    38913       +5     
==========================================
+ Hits        36368    36371       +3     
- Misses       2540     2542       +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 merged commit 8b00542 into main Aug 31, 2026
33 of 38 checks passed
@mcollina
mcollina deleted the fix/agent-goaway-pending-pool branch August 31, 2026 10:40
@github-actions github-actions Bot mentioned this pull request Aug 31, 2026
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.

3 participants