fix(tests): bound e2e dev-server teardown so CI stops failing - #103
Merged
Conversation
The `.md suffix end-to-end` suite boots `next dev --turbopack` via `bunx` and tears it down with `server.kill(); await server.exited`. `kill()` only SIGTERMs the direct bunx child; the next-server/Turbopack grandchildren survive, so `.exited` never resolves and afterAll blocks until Bun's setDefaultTimeout(120000) -- failing the file and turning CI red on every run since PR #97 (the fragility was latent since the teardown landed in PR #81). PR #102 (timeout-minutes: 30) does not help: that bounds the GitHub job timeout, but the job finishes in ~3-6 min and the 120s is Bun's per-hook timeout, a different layer. Spawn the dev server detached so it leads its own process group, then tear the whole group down: SIGTERM, race `.exited` against a 3s budget, escalate to SIGKILL if it hasn't exited. The awaited exit is now bounded, so teardown can no longer hang regardless of how the child handles SIGTERM -- and the full tree is reaped, keeping the port/CPU free for the later Chromium tests. Validated: bun run typecheck, biome check, and bun test tests/e2e/llm-endpoints.test.ts (22 pass). Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why CI is red
Every run on
mainsince PR #97 fails on a single test hook:The failing file is
tests/e2e/llm-endpoints.test.ts. It boots a Next dev server inbeforeAlland tears it down inafterAll:beforeAllsucceeded — the server came up.(unnamed)failure is Bun's report of theafterAllhook timing out. In run30572654711the last named test passes at18:58:38, and the failure fires exactly 120 s later at19:00:38(=setDefaultTimeout(120000)+ overhead).server.kill()signals only the directbunxchild. The tree it spawned (bunx → next dev → next-server → Turbopack workers) survives, so.exitednever resolves and the hook runs out the 120 s timeout.The teardown code has been unchanged since PR #81; PR #97 (
fix(routes): make docs root canonical) made the root route a heavier compiled render, which pushed the SIGTERM-doesn't-cleanly-exit defect past the 120 s threshold deterministically.What changed
In
tests/e2e/llm-endpoints.test.ts, one surgical change to teardown:detached: trueso it leads its own process group.killProcessGroup(pid, signal)helper that signals the whole group (process.kill(-pid, …)), with a fallback to the direct child.afterAllto: SIGTERM the group → race.exitedagainst a 3 s budget → escalate to SIGKILL if it hasn't exited.The awaited exit is now bounded, so teardown can no longer hang regardless of how the child responds to SIGTERM — and the full process tree is reaped, keeping the port/CPU free for the later Chromium imagegen tests (the original intent of
afterAll's comment).Validation
bun run typecheck— passbunx biome check tests/e2e/llm-endpoints.test.ts— passbun test tests/e2e/llm-endpoints.test.ts— 22 pass, 0 fail (54 s; teardown completes cleanly)ubuntu-latest-specific and doesn't reproduce in this sandbox).🤖 Generated with Claude Code