Repository navigation
fix(ext/node): send http2 GOAWAY before stream RSTs so peer sees session destroy code - #33637
Conversation
…ion destroy code Enables tests/node_compat/runner/suite/test/parallel/test-http2-propagate-session-destroy-code.js Co-authored-by: Divy Srivastava <me@littledivy.com>
fibibot
left a comment
There was a problem hiding this comment.
LGTM. Verified the fix logic:
The reordering moves the GOAWAY-submit-and-drain block from after state.streams.forEach(stream => stream.destroy(error)) to before it, so the wire order becomes:
handle.goaway(code, 0)queues a GOAWAY frame with the session-level error code (e.g.NGHTTP2_REFUSED_STREAM = 7).- The synchronous
while (!socket.destroyed) { socket.write(handle.getOutgoingChunk()) }flushes the GOAWAY to the wire. state.streams.forEach(stream => stream.destroy(error))then queues per-streamRST_STREAMframes and drains them.
That ordering matters for the upstream test: when the peer receives GOAWAY first, it sets session[kSession].goawayCode = 7 before the per-stream RST_STREAM arrives, so the peer's stream destroy path picks up the session-level error and surfaces "Session closed with error code 7" (matching the test's errRegEx = /Session closed with error code 7/). Without the reorder, RST_STREAM lands first, the peer's stream goes to ERR_HTTP2_STREAM_ERROR, and session.goawayCode is still null at that point — the propagation test fails.
Other things I checked:
- Skip conditions preserved:
typeof code === "number" && (state.flags & SESSION_FLAGS_CLOSED) === 0 && socket && !socket.destroyed && typeof handle.goaway === "function"— same five conditions as before, just moved. The graceful-close path (session.close()→ SESSION_FLAGS_CLOSED set → submitGoaway already done) and thedestroy(null)re-entry fromkMaybeDestroyboth correctly skip this block. ✓ - Drain-loop termination: the
whilebreaks on!chunk || chunk.byteLength === 0. After a GOAWAY frame is submitted there's no further frame production from this side, sogetOutgoingChunk()returns empty within a small bounded number of iterations. ✓ - Stream destroy still drains its own RSTs synchronously: per-stream
submitRstStream+scheduleSendPendingruns after this block, so RST_STREAM frames still hit the wire (just behind the GOAWAY). ✓ - Test enrollment alphabetically positioned:
test-http2-priority-event<test-http2-propagate-session-destroy-code<test-http2-raw-headers-defaults. ✓
CI fully green: 133 SUCCESS, 0 FAILURE, 2 SKIPPED. All 36 test node_compat shards (3 × 6 platforms × debug+release) pass, all 12 test unit_node shards pass.
Summary
Enables
test-http2-propagate-session-destroy-codein node_compat suite.Test plan
cargo test --test node_compat -- test-http2-propagate-session-destroy-code