You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mux-h2: write_streams arms the frontend timeout on an ACK-only pass, so a PING-only peer holds a stuck session open indefinitely #1489
ConnectionH2::poll_read_target documents that PING, WINDOW_UPDATE and SETTINGS must not reset the frontend timeout. ConnectionH2::write_streams resets it anyway, on every pass that has something to send.
The contradiction, in the tree
poll_read_target carries this, explicitly:
PING, WINDOW_UPDATE, SETTINGS must NOT reset it, otherwise a peer sending periodic PINGs prevents timeout detection on stuck sessions
The read path honours it. But write_streams opens with an unconditional ConnectionH2::arm_timeout, and any pass with something to send reaches it — including a pass whose only output is a PING ACK or a SETTINGS ACK.
So the rule holds on the read side and is undone on the write side, for exactly the frame types it names.
Measured
front_timeout 600 s, one stream opened at t=10 ms, reading Connection::poll_timeout after each pass:
event
published deadline
HEADERS @ 10 ms
10 ms ✓ correct
PING @ 10 s
10 s ← reset
empty pass @ 20 s
unchanged ✓
WINDOW_UPDATE @ 30 s
unchanged ✓
SETTINGS @ 40 s
40 s ← reset
PING @ 500 s
500 s ← reset
The three that move are exactly the three that queue an acknowledgement — a PING ACK or a SETTINGS ACK gives the write path something to send, which arms the timeout. WINDOW_UPDATE queues nothing, which is why it correctly does not move.
Consequence
front_timeout never fires on a PING-only peer. A client that opens a connection and sends a PING every few minutes holds a session open indefinitely, which is the Slowloris shape the documented rule exists to prevent.
The per-stream idle deadline is not affected — it is what still retires individual streams, and it is what the simulator's tick-boundary property covers. The gap is the connection-level deadline specifically.
On the fix
The narrow fix is to arm the timeout on a pass that sends stream data rather than on any pass with output, so an acknowledgement-only pass does not count as liveness. Worth checking against the close/drain paths, which also reach write_streams and do want their timeout armed.
Provenance
Found by the H2 deterministic simulator (#1359 C4). The simulator does not assert the connection-level idle deadline, deliberately: asserting today's behaviour would certify the gap.
The frontend deadline is now armed on application-stream activity in either direction: inbound unchanged (DATA payload, HEADERS), outbound gated at the H2StreamId::Other arm of ConnectionH2::handle_write on size > 0, replacing the unconditional arm_timeout() at the top of write_streams.
Measured before and after, front_timeout 600 s, one stream at 10 ms — t0 + 600.01 s is the correct answer:
event
before
after
PING @ 10 s
t0 + 610 s
t0 + 600.01 s
SETTINGS @ 40 s
t0 + 640 s
t0 + 600.01 s
PING @ 500 s
t0 + 1100 s
t0 + 600.01 s
Production arm_timeout() call sites stay at three, which LIFECYCLE §9 invariant 9 asserts.
A larger exposure than this issue described
Mux::drive_frontend_shutdown_io sets force_h2_write unconditionally for an H2 frontend, so a draining connection still in H2State::Header reached write_streams on every shutting-down poll. The unconditional arm therefore made a draining session immune to front_timeout for the entire drain, byte or no byte. That is now bounded by graceful_shutdown_deadline and by Mux::timeout's own draining branch.
Direction
handle_write serves backend H2 too, so an upstream sending keepalive PINGs no longer renews backend_timeout either — a stuck upstream that only pings now times out. Response HEADERS/DATA reads still renew it.
The documentation inconsistency was the bug
poll_read_target's prose rule, LIFECYCLE §7.1 and §9 invariant 9, invariant 22 and its duplicate in mod.rs, and the writable() dispatch comment — which claimed "Reset the timeout here … so that control frame writes don't reset it", precisely the thing it failed to do — are all now consistent with the code.
On the test
Four tests, each pairing a negative leg with a positive leg on the same connection, because an assertion that only checks "the deadline did not move" passes against a build that never arms at all — the opposite defect, and worse, since it turns front_timeout into an unconditional session cap. Two independent reverts prove it: restoring the unconditional arm reddens all four on their negative legs, and neutering the gate to if false reddens the same four on their positive legs.
Activity
test(sim): deterministic H2-core simulation (#1359 C4)
test(sim): deterministic H2-core simulation (#1359 C4) (#1485)
fix(mux-h2): arm the frontend timeout on stream bytes, not on any wri…
FlorentinDUBOIS commentedon Sep 24, 2026
Fixed in #1494 (
ad425e0b).The frontend deadline is now armed on application-stream activity in either direction: inbound unchanged (DATA payload, HEADERS), outbound gated at the
H2StreamId::Otherarm ofConnectionH2::handle_writeonsize > 0, replacing the unconditionalarm_timeout()at the top ofwrite_streams.Measured before and after,
front_timeout600 s, one stream at 10 ms —t0 + 600.01 sis the correct answer:Production
arm_timeout()call sites stay at three, which LIFECYCLE §9 invariant 9 asserts.A larger exposure than this issue described
Mux::drive_frontend_shutdown_iosetsforce_h2_writeunconditionally for an H2 frontend, so a draining connection still inH2State::Headerreachedwrite_streamson every shutting-down poll. The unconditional arm therefore made a draining session immune tofront_timeoutfor the entire drain, byte or no byte. That is now bounded bygraceful_shutdown_deadlineand byMux::timeout's own draining branch.Direction
handle_writeserves backend H2 too, so an upstream sending keepalive PINGs no longer renewsbackend_timeouteither — a stuck upstream that only pings now times out. Response HEADERS/DATA reads still renew it.The documentation inconsistency was the bug
poll_read_target's prose rule, LIFECYCLE §7.1 and §9 invariant 9, invariant 22 and its duplicate inmod.rs, and thewritable()dispatch comment — which claimed "Reset the timeout here … so that control frame writes don't reset it", precisely the thing it failed to do — are all now consistent with the code.On the test
Four tests, each pairing a negative leg with a positive leg on the same connection, because an assertion that only checks "the deadline did not move" passes against a build that never arms at all — the opposite defect, and worse, since it turns
front_timeoutinto an unconditional session cap. Two independent reverts prove it: restoring the unconditional arm reddens all four on their negative legs, and neutering the gate toif falsereddens the same four on their positive legs.