test: isolate store singleton from cross-file bun leaks#386
Merged
Conversation
Contributor
✅MegaLinter analysis: Success
Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts MegaLinter is graciously provided by OX Security |
JoshMock
approved these changes
May 29, 2026
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 BunCI failure onmain, which started at commit 2297c98 (fix: respect --json flag on --help for root and groups #373) and fails attest/config/store.test.ts:25(store > getResolvedConfig > returns undefined before any config is set).src/config/store.tsis a module-level singleton.bun testruns all test files in a shared process (and distributes them across concurrent workers that share module state), unlikenode --test, which isolates each file. Sibling suites such astest/lib/es-client.test.tsleave_configset to{ context: {} }in theirafterEach, so whenstore.test.ts's first test runs after one of them in the same worker, the initial-state assertion fails. The node runner never sees this because it isolates files.test/cli.test.tsandtest/factory.test.ts, which perturbed bun's per-worker file scheduling enough to surface this pre-existing latent leak._testResetConfig()in abeforeEach(in addition toafterEach), so the test no longer depends on residual global state and is order-independent under both bun and node.Test plan
npx tsc --noEmitpassesnpx tsx --test test/config/store.test.tspasses (node runner)bun test test/lib/es-client.test.ts test/config/store.test.tspasses (bun, polluter ordering)Test Bunjob is green on all three OS runners