Skip to content

fix(test): stop test servers when their test process dies - #1034

Open
TheAlexLichter wants to merge 1 commit into
mainfrom
fix/test-server-orphans
Open

TheAlexLichter wants to merge 1 commit into
mainfrom
fix/test-server-orphans

Conversation

@TheAlexLichter

Copy link
Copy Markdown
Member

Integration tests start dev servers with spawn from a Vitest worker but nothing stops those servers if the test process dies.

This PR starts test servers through a small supervisor (test/server-supervisor.ts):

  • Runs the server in its own process group and uses its stdin pipe from the test process as a lifeline.
  • When the pipe closes (the test process is gone, even after SIGKILL), on SIGTERM/SIGINT/SIGHUP, or when the server exits, it stops the whole group: SIGTERM first, then SIGKILL after 3 s.
  • Exits only once the group is empty, and passes on the server's exit code or signal.

Known limits:

  • Windows uses taskkill /T /F, and the new test is skipped there; this path is unverified (I only tested on my MBP)
  • SIGKILLing the supervisor itself would still orphan its server. Nothing in the normal flow does that.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Cloudflare builds and deploys previews for this pull request. Learn more about Cloudflare previews.

Worker Status Deployment Commit
void-cloud Deployed Preview 1968022

Updated: Dec 4, 2026, 11:45 UTC | Dashboard

@TheAlexLichter
TheAlexLichter marked this pull request as ready for review December 4, 2026 15:02
@TheAlexLichter
TheAlexLichter requested a review from cpojer December 4, 2026 15:02

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.

1 participant