Repository navigation
fix(h2): replace a connection whose PING goes unanswered - #6074
Conversation
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
left a comment
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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) beforeheadersTimeout(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 unackedsession.ping()never calls back.Reproduced on
mainwith the TCP proxy fromtest/http2-unresponsive-connection.js. After the proxy goes dark, the client sends requests withsignal: AbortSignal.timeout(500)for 8 seconds:main,pingInterval: 60e3X X X X X X X X X X X X X X X Xmain,pingInterval: 1000X X X X X X X X X X X X X X X XpingInterval: 1000X X X X ok ok ok ok …Changes
Features
N/A
Bug Fixes
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 twopingIntervals (up to 2 minutes by default), even when no stream times out on it.disconnectreportsconnection unresponsiveinstead of"PING" errored - type HTTP2 ping cancelled.test/http2-unresponsive-connection.js: after the proxy goes dark and no request is sent, the pool disconnects withUND_ERR_SOCKETand the next request succeeds on a new connection. Onmainthe disconnect never happens.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