Skip to content

fix(tests): bound e2e dev-server teardown so CI stops failing - #103

Merged
nibzard merged 1 commit into
mainfrom
fix/e2e-dev-server-teardown
Jul 31, 2026
Merged

fix(tests): bound e2e dev-server teardown so CI stops failing#103
nibzard merged 1 commit into
mainfrom
fix/e2e-dev-server-teardown

Conversation

@nibzard

@nibzard nibzard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Why CI is red

Every run on main since PR #97 fails on a single test hook:

(fail) .md suffix end-to-end > (unnamed) [120007ms]
  ^ a beforeEach/afterEach hook timed out for this test.
298 pass, 1 fail

The failing file is tests/e2e/llm-endpoints.test.ts. It boots a Next dev server in beforeAll and tears it down in afterAll:

afterAll(async () => {
  server?.kill();          // SIGTERM → only the direct bunx child
  await server?.exited;    // ← hangs here
});
  • All ~24 named tests pass, so beforeAll succeeded — the server came up.
  • The (unnamed) failure is Bun's report of the afterAll hook timing out. In run 30572654711 the last named test passes at 18:58:38, and the failure fires exactly 120 s later at 19:00:38 (= setDefaultTimeout(120000) + overhead).
  • server.kill() signals only the direct bunx child. The tree it spawned (bunx → next dev → next-server → Turbopack workers) survives, so .exited never 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.

Note: PR #102 (ci/bound-workflow-runtime, which only adds timeout-minutes: 30) does not fix this — it bounds GitHub's job timeout, but the job finishes in ~3–6 min and the 120 s is Bun's per-hook timeout. Different layer. This PR is the actual fix; #102 can be closed.

What changed

In tests/e2e/llm-endpoints.test.ts, one surgical change to teardown:

  1. Spawn the dev server with detached: true so it leads its own process group.
  2. Add a killProcessGroup(pid, signal) helper that signals the whole group (process.kill(-pid, …)), with a fallback to the direct child.
  3. Rewrite afterAll to: SIGTERM the group → race .exited against 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 — pass
  • bunx biome check tests/e2e/llm-endpoints.test.ts — pass
  • bun test tests/e2e/llm-endpoints.test.ts22 pass, 0 fail (54 s; teardown completes cleanly)
  • Hosted CI is the final confirmation (the hang is ubuntu-latest-specific and doesn't reproduce in this sandbox).

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 30, 2026 8:59pm

Request Review

@nibzard
nibzard merged commit 245148b into main Jul 31, 2026
3 checks passed
@nibzard
nibzard deleted the fix/e2e-dev-server-teardown branch July 31, 2026 09:25
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