0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00

test(compiler-test-utils): child runs never outlive the test worker; lost build errors fail fast

Harness hygiene (mutation run r3b follow-up 1): a built entry run by the
build harness (`run()`, e.g. the server of an Rsbuild Start build) ran in a
`node --eval` child with no time limit and nothing tying it to the test
worker. When a vitest worker was killed on a timeout, a child stuck in a
loop was reparented to init and spun at 100% CPU for hours.

- New `run-node.ts` (`runNodeProgram`): runs the program with a time limit
  (default 30 s, SIGKILL, clear error) and a watchdog thread (`--import`)
  that SIGKILLs the child once its parent process is gone, which works even
  while the program's thread spins in a synchronous loop. Used by the build
  harness's `run()` and router-plugin's code-splitter runtime test.
- `withBuildEnvironment`: an error no one handles while a build runs fails
  the build (a throw in a sync Rspack `compile` hook leaves `rsbuild.build()`
  pending forever).
- Rsbuild dev harness: a compile Rspack gives up on (`compiler.hooks.failed`,
  e.g. a throw in `processAssets`) rejects the compile wait with its error at
  once instead of after `compileTimeout`.

Verified: SIGKILLing the vitest worker while an Rsbuild Start build's
server spins leaves no process (with the watchdog disabled, the child is
reparented to systemd and keeps spinning). Control tests in run-node.test.ts
and rsbuild-dev-server.test.ts.

Fail fast instead of a time limit: spc:6793 (Rsbuild builds failed after the
60 s test timeout, now at once on an assertion), spc:7471 (Rsbuild dev
compile wait of 20 s, now the real TypeError at once).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sheraff 2026-10-17 14:47:38 +02:00
commit 835b7b72a3
No known key found for this signature in database
7 changed files with 301 additions and 23 deletions