test: cover RST_STREAM and the Content-Length-mismatch arm of h2 header-time completion

Closed
RO
5d ago
+91-17

What does this PR do?

Test-only follow-up to #36941 (the header-time terminal detach fix in the HTTP/2/3 fetch client). Review of that change found two halves of its contract unasserted; this adds both to test/js/web/fetch/fetch-http2-adversarial.test.ts:

  1. RST_STREAM on completion. When a Content-Length: 0 response completes at header time the stream is still open from the server's side, so the deliver loop abandons it with RST_STREAM(CANCEL); without that the server is left holding the stream half-open against MAX_CONCURRENT_STREAMS. The existing test now asserts the server received RST_STREAM(CANCEL) on stream 1, matching the state.rst assertions the suite already has for the other two detach-leaves-stream-open paths.

  2. Coalesced stray DATA. New test: the same content-length: 0 + SSE HEADERS with a 1-byte DATA frame in the same TLS record. The stray byte contradicts the declared length, so finish_stream rejects with HTTP2ContentLengthMismatch (RFC 9113 section 8.1.1). The head is already valid when the mismatch is detected, so fetch() resolves and the error lands on the body read, mirroring the existing mid-body mismatch behavior. This arm of the #36941 branch had no coverage.

How did you verify your code works?

Both tests pass 3/3 consecutive runs against the debug+ASAN build on current main, and the whole fetch-http2-adversarial.test.ts file passes (17 tests).

Note for the fail-before check: the fix these tests cover is already merged (#36941), so there is no in-tree revision where they fail without a src change. On the pre-#36941 tree both scenarios crash the child with the client.h2.is_none() teardown assertion rather than producing the asserted outputs.


no test proof · iteration 1 · Platform-specific test-only change; deferring to CI.