Skip to content

test: add unexpected disconnect guards to two more h2 tests - #5825

Open
zeexzeex wants to merge 1 commit into
nodejs:mainfrom
zeexzeex:test/251-h2-happy-path-guards
Open

zeexzeex wants to merge 1 commit into
nodejs:mainfrom
zeexzeex:test/251-h2-happy-path-guards

Conversation

@zeexzeex

Copy link
Copy Markdown
Contributor

Adds the disconnect guard pattern from docs/docs/best-practices/writing-tests.md to two more HTTP/2 test files, so a silent disconnect/reconnect cycle fails the test instead of passing unnoticed. Follow-up to #5686.

Files covered (3 guards): http2-informational.js (1), http2-timeout.js (2).

Of the 21 http2-* files still without a guard, these two are the only ones where an unexpected disconnect is a fault. The rest fall into four groups: the disconnect is deliberate (http2-goaway*.js, http2-abort.js, http2-refused-stream.js, http2-stream.js, http2-request-never-settles.js, http2-max-concurrent-streams-zero.js), the h2 internals are mocked with no real connection (http2-late-data.js, http2-window-size.js, http2-response-after-completion.js, http2-ping-errors.js, http2-invalid-session.js), no server is started at all (http2-resume-null-request.js, http2-stream-internal-error.js, http2-destroy-after-failed-stream.js, http2-goaway-retry-body.js), or teardown itself is under test (http2-stream-cancel.js, http2-instantiation.js).

http2-invalid-connection-headers.js looked like a candidate but is not one: the session does close there, and the test already asserts connectCount === 2 for the reconnect that follows.

http2-body.js and the connect-* group are left for the follow-up already announced in #251.

Verified: both files pass with the guards in place, and lint is clean. Note that neither guard turns a currently failing case green; they are there to catch a regression, which is what the issue asks for.

Refs: #251

undici's Client reconnects on its own, so a socket that drops mid-test
is followed by a silent reconnect and the test still passes. The guard
from docs/docs/best-practices/writing-tests.md turns that into a
failure.

http2-informational.js and http2-timeout.js keep their session up for
the whole test, so an unexpected disconnect there is a real fault.
Follow-up to nodejs#5686.

Refs: nodejs#251
@zeexzeex
zeexzeex force-pushed the test/251-h2-happy-path-guards branch from 9ea6630 to 61ce494 Compare September 17, 2026 05:19
@codecov-commenter

codecov-commenter commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.53%. Comparing base (bfea020) to head (61ce494).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5825   +/-   ##
=======================================
  Coverage   93.53%   93.53%           
=======================================
  Files         110      110           
  Lines       39773    39773           
=======================================
  Hits        37200    37200           
  Misses       2573     2573           

☔ 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.

This branch has not been deployed

No deployments
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.

3 participants