Skip to content

test: harden http test server lifecycle to fix flaky FormData EPIPE#10820

Merged
jasonsaayman merged 2 commits intov1.xfrom
test/improve-http-server-test-resilience
Apr 28, 2026
Merged

test: harden http test server lifecycle to fix flaky FormData EPIPE#10820
jasonsaayman merged 2 commits intov1.xfrom
test/improve-http-server-test-resilience

Conversation

@jasonsaayman
Copy link
Copy Markdown
Member

@jasonsaayman jasonsaayman commented Apr 28, 2026

Summary by cubic

Hardened the test HTTP server lifecycle and stabilized flaky cases by using ephemeral ports, graceful shutdown, and one‑shot agents. Also added small retries and ephemeral ports to HTTP/2 session and Safari abort tests to prevent EPIPE and “Premature close” flakes in CI.

Description

  • Summary of changes
    • Default startHTTPServer to port 0; use OS-assigned ephemeral ports.
    • stopHTTPServer: try graceful close first; force-close after a short grace; always untrack; handleFormData now drains unread request bytes on parse errors.
    • FormData test: ephemeral port, new http.Agent({ keepAlive: false }), Connection: 'close', destroy agent in finally, and { retry: 2 }.
    • HTTP/2 session tests: rely on ephemeral ports (stop passing fixed ports), add { retry: 2 }, and set { timeout: 15000 } where needed.
    • Safari abort test: add { retry: 2 } for the ETIMEDOUT case.
  • Reasoning
    • Avoids TIME_WAIT/keep-alive pool reuse and h2 session teardown races that showed up as EPIPE or “Premature close” under CI load.
  • Additional context
    • Changes are test-only; no runtime code or public API affected.

Docs

  • Add a note in /docs/ on using ephemeral ports for test servers, preferring graceful shutdown before force-closing, draining unread request bodies, using non‑keep‑alive agents for one‑shot requests, and applying small retries for timing‑sensitive tests (e.g., HTTP/2 sessions, Safari abort scenarios).

Testing

  • No new tests. Updated the existing SpecCompliant FormData test, HTTP/2 session tests, and the Safari abort test to improve reliability (ephemeral ports, one‑shot agent, headers, retries, timeouts).

Semantic version impact

  • Patch (tests only; no public API or behavior change).

Written for commit 977ae5a. Summary will update on new commits. Review in cubic

@jasonsaayman jasonsaayman self-assigned this Apr 28, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@jasonsaayman jasonsaayman merged commit 9fcdf48 into v1.x Apr 28, 2026
25 checks passed
@jasonsaayman jasonsaayman deleted the test/improve-http-server-test-resilience branch April 28, 2026 17:44
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.

1 participant