Repository navigation
ci: harden pre-commit vitest hook against teardown hangs - #2542
Merged
Merged
Conversation
vitest 4.1.4 forks pool zombies workers for days when something in the module graph leaves an open handle at process exit — 37 such processes found across workspaces, some running 2 days at 0% CPU. Switch test:unit to --pool=threads and wrap npm run test:unit in a portable shell timeout so a sporadic hang aborts pre-commit in 60s instead of blocking the developer indefinitely. Add the full tests/ suite to Build Check CI (it previously only ran via pre-commit) and run Build Check on pushes to main, not just PRs. Root cause of the hang tracked in #2541. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
added a commit
that referenced
this pull request
Apr 20, 2026
The pino-pretty transport spawns a worker thread and registers
process.on('exit', ...), which holds the event loop open at vitest
teardown — resulting in zombie workers that could hang pre-commit for
hours. 37 such processes had accumulated across Conductor workspaces,
some running 2 days at 0% CPU.
Treat NODE_ENV=test and VITEST=true (auto-set by vitest) as non-dev so
tests use the default synchronous stdout destination with no worker
thread and no exit listener. Six back-to-back runs confirm the hang is
eliminated.
The defensive timeout wrapper and threads pool from #2542 stay as
belt-and-suspenders against future regressions.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
3 of 4 tasks
bokelley
added a commit
that referenced
this pull request
Apr 20, 2026
The pino-pretty transport spawns a worker thread and registers
process.on('exit', ...), which holds the event loop open at vitest
teardown — resulting in zombie workers that could hang pre-commit for
hours. 37 such processes had accumulated across Conductor workspaces,
some running 2 days at 0% CPU.
Treat NODE_ENV=test and VITEST=true (auto-set by vitest) as non-dev so
tests use the default synchronous stdout destination with no worker
thread and no exit listener. Six back-to-back runs confirm the hang is
eliminated.
The defensive timeout wrapper and threads pool from #2542 stay as
belt-and-suspenders against future regressions.
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
added a commit
that referenced
this pull request
Jun 11, 2026
…ets (#5484) Root-cause fix for the sporadic vitest pre-commit teardown hang (#2541): 7 background setInterval loops (crawler x3, luma/sync, addie/jobs/scheduler, 2 scheduled/*) were missing .unref(), so a test that triggers one keeps the worker's event loop alive at exit. These are server-internal background loops (the server stays alive via its HTTP listener, not these timers), so unref is correct in production and matches the 12+ siblings that already do it. Also raises with-timeout budgets (test:unit 60->180s, server-unit 120->240s): the suites grew past the caps set in #2542, so under multi-workspace CPU contention they were SIGTERM'd mid-run even without a hang. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.
Summary
test:unitto--pool=threads. Vitest 4.1.4's defaultforkspool zombies workers for days when something in the module graph leaks an open handle at process exit (37 such processes were found across Conductor workspaces, some running 2 days at 0% CPU, stuck at teardown).npm run test:unitinscripts/with-timeout.sh 60for pre-commit. A sporadic hang now aborts in 60s instead of blocking the developer indefinitely. The wrapper is portable (usestimeout/gtimeoutwhen present, bash trap/kill fallback otherwise) and sends SIGTERM first with a 5s grace window before SIGKILL.tests/suite to the Build Check CI workflow. It was only running via pre-commit — any skip (--no-verify, hung hook) previously meant zero coverage.main, not just PRs. Concurrency group avoids duplicate runs on PR merge.Root-cause investigation tracked in #2541 — likely candidates to audit for unclean shutdown: DB pool, addie singletons, stripe client, email clients.
Test plan
--pool=threads(587 tests in ~3s)secsarg yields 2🤖 Generated with Claude Code