Skip to content

fix(h2): replace a connection whose PING goes unanswered - #6074

Merged
mcollina merged 1 commit into
nodejs:mainfrom
MIbtehajNasar:fix-6073-h2-unacked-ping
Nov 20, 2026
Merged

mcollina merged 1 commit into
nodejs:mainfrom
MIbtehajNasar:fix-6073-h2-unacked-ping

Conversation

@MIbtehajNasar

Copy link
Copy Markdown
Contributor

This relates to...

Fixes #6073

Rationale

#6052 replaces a silently dead HTTP/2 connection when a stream times out on it. In #6073 the requests fail on the application's own timeout (an AbortSignal) before headersTimeout (300s by default), so no stream ever times out. The pool keeps sending every new request to the dead session and never recovers. The periodic PING doesn't catch it either, because an unacked session.ping() never calls back.

Reproduced on main with the TCP proxy from test/http2-unresponsive-connection.js. After the proxy goes dark, the client sends requests with signal: AbortSignal.timeout(500) for 8 seconds:

after the connection goes dark connections
main, pingInterval: 60e3 X X X X X X X X X X X X X X X X 1
main, pingInterval: 1000 X X X X X X X X X X X X X X X X 1
this PR, pingInterval: 1000 X X X X ok ok ok ok … 2

Changes

Features

N/A

Bug Fixes

  • When a periodic PING is due and the previous one is still unacked, the session is reset with the same retryable SocketError('HTTP/2: connection unresponsive') as the stream-timeout probe from fix(h2): replace a connection that stops responding after a stream timeout #6052. A dead connection is replaced within two pingIntervals (up to 2 minutes by default), even when no stream times out on it.
  • Resetting the session cancels the pending PING. Its callback no longer overwrites the socket error, so disconnect reports connection unresponsive instead of "PING" errored - type HTTP2 ping cancelled.
  • Added a test to test/http2-unresponsive-connection.js: after the proxy goes dark and no request is sent, the pool disconnects with UND_ERR_SOCKET and the next request succeeds on a new connection. On main the disconnect never happens.
  • Documented the new behavior under h2Options.pingInterval.

Breaking Changes and Deprecations

N/A. A PING ack only fails to arrive within pingInterval (60s by default) when the connection is dead or the event loop has been blocked for about that long.

Status

A connection that silently died (dropped by a NAT or load balancer
without a FIN or RST) was only replaced when a stream timed out on it
(nodejs#6052). When the application aborts its requests before
headersTimeout, no stream times out, so every new request kept going to
the dead session. The periodic PING didn't help: an unacked
session.ping() never calls back.

When the next periodic PING is due and the previous one is still
unacked, reset the session with the same 'HTTP/2: connection
unresponsive' SocketError as the stream-timeout probe. The PING that
the reset cancels no longer overwrites that error on the socket.

Fixes nodejs#6073

@DLazaridis DLazaridis left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the implementation against #6073 and the linked rationale.

The periodic PING path now detects an unacked PING and resets the session with the same HTTP/2: connection unresponsive SocketError. The PING callback uses socket[kError] ??= ..., so the reset reason is preserved and disconnect reports connection unresponsive instead of the cancelled PING error. busy() continues to gate new streams while a probe timeout is active, and the new regression test covers the no-stream-timeout case.

I ran the h2 suite, including test/http2-unresponsive-connection.js; all tests pass. Documentation under h2Options.pingInterval is updated.

No blocking concerns; approving.

@codecov-commenter

codecov-commenter commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.58%. Comparing base (1f45224) to head (a68f552).
⚠️ Report is 49 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6074   +/-   ##
=======================================
  Coverage   91.58%   91.58%           
=======================================
  Files         113      113           
  Lines       44001    44018   +17     
=======================================
+ Hits        40298    40314   +16     
- Misses       3703     3704    +1     

☔ 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 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina
mcollina merged commit 0a97cdf into nodejs:main Nov 20, 2026
38 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 20, 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.

HTTP/2 (default since v8): requests keep being dispatched onto a silently dead h2 session until headersTimeout, no PING health check

4 participants