Repository navigation
fix(test): stop leaking workflow-artifact temp dirs from vitest workers - #2560
Merged
Merged
Conversation
The setup file created one mkdtemp per worker process and never removed it. Under the default isolated forks pool that is one directory per test file per run, and tinypool tears workers down with SIGTERM then SIGKILL after 500 ms, so even an exit-hook cleanup loses that race under load. Measured damage: 330k leaked atomic-test-workflow-artifacts-* entries in the OS temp dir (of 1.3M total), enough to make every mkdtemp under tmpdir() machine-wide take seconds and push real CLI tests past their structural budgets. - New test/global-setup-workflow-artifacts.ts creates one directory per run in the orchestrator; workers inherit the env var and create nothing; teardown removes it after the pool is gone. Wired into all three projects. - setup-workflow-durability.ts keeps a fallback for invocations that bypass the repo config, now with exit cleanup and a SIGTERM-to-exit conversion (Node's default SIGTERM disposition skips exit listeners). - The globalSetup contract test now asserts the artifact setup on all three projects and the native build on unit/integration only. Verified: three repeated suite runs leak zero directories. Assistant-model: Claude Fable 5
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/setup-workflow-durability.tscreated onemkdtempper vitest worker process and never removed it. Under the default isolated forks pool that is one directory per test file per run. Measured damage on a dev machine: 330k leakedatomic-test-workflow-artifacts-*entries (of 1.3M total temp-dir entries), which made everymkdtempundertmpdir()machine-wide take seconds and pushed real-CLI tests (e.g.release-publisher-contracts) past their structural budgets — 145 s for a sequence that takes 5 s in a clean temp dir.Changes
test/global-setup-workflow-artifacts.ts(new): creates one directory per run in the orchestrator process; every worker inheritsENV_WORKFLOW_ARTIFACT_DIRand creates nothing; the globalSetup teardown removes it after the pool is gone. Wired into all three projects.test/setup-workflow-durability.ts: keeps a fallback for invocations that bypass the repo config, now with exit-time cleanup plus a SIGTERM→exit conversion — tinypool ends forks with SIGTERM (then SIGKILL after 500 ms), and Node's default SIGTERM disposition skipsexitlisteners entirely.test/ci/ci-workflow-contracts.test.ts: the globalSetup contract now asserts the artifact setup on all three projects and the native build on unit/integration only.Notes
npm run checkand all 47 ci-contract tests green.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Greptile Summary
This change centralizes workflow-artifact temporary-directory ownership in Vitest’s orchestrator and retains worker-side cleanup for configuration-bypassing test runs. The artifact lifecycle was exercised twice through the root Vitest configuration with concurrent workers: each run used one shared directory while tests were active, and that directory no longer existed after Vitest exited. The temporary-directory leak concern was disproved by these executions. No defects were found.
Confidence Score: 5/5
Safe to merge based on the exercised root-config test lifecycle.
Two independent concurrent-worker executions confirmed that workers inherit one orchestrator-owned artifact directory, can use it during the run, and that it is removed after the run exits. No publishable defects remain.
Files Needing Attention: No files need follow-up attention.
What T-Rex did
Reviews (1): Last reviewed commit: "fix(test): stop leaking workflow-artifac..." | Re-trigger Greptile