Repository navigation
fix(test): Vitest reports a failure whose stack names a Bun builtin - #35384
Conversation
[Medium impact] The PR appears safe to merge; no blocking issues were found. SummaryPatches Vitest’s error reporting to skip directories when reading source maps.
Reviews (1) · Last reviewed commit: "fix(test): report a failing test whose s..." · Reviewed by Greptile |
|
STATUS: ready. Head 8bfad4b. CI-flake fix from the unit-shard triage; load rule run locally (pnpm tc, typecheck:ci, code-quality, anti-slop, oxlint, ast-grep scan and gates) plus the affected tests. Review requested from e9-reviewer. Not merged. |
|
No actionable comments were generated in the recent review.
|
ELI5
Unit shards sometimes failed with a confusing
EISDIR: illegal operation on a directoryfrom inside Vitest, instead of naming the test that actually failed. Tests run under Bun, and Bun labels its built-in functionsnativein error stacks. Vitest tooknativefor a file, found our repo'snative/folder, and crashed trying to read a folder as a file. This tells Vitest to read only real files, so the actual failing test shows up again.What Changed
Before:
at map (native:1:11)) made Vitest's main process throwEISDIRingetSourceMap.Tests (1)).CommentMarkdown.parse-reusetimed out).After: the same failure is reported as a normal failing test, with its real error.
Mechanism:
config/patches/[email protected]). ThegetSourceMaphook inTestRun.syncUpdateStacksnow also requiresstatSync(file).isFile()beforereadFileSync.native:1:11as the pathnative, which resolves against the repo root. It existed (native/holds our native modules), so it was read.pnpm-workspace.yamlpatchedDependencies.patch_hash=on the existing vitest entries; nothing else is re-resolved.Why
Why patch Vitest rather than a test. Any test can hit this: it fires for whichever test fails with a Bun builtin frame in its stack. The bug is Vitest treating a relative frame name as a readable file. It isn't fixable from config:
onStackTraceruns after the source-map read.Alternatives considered:
native/would touch build and packaging.Not fixed here: the underlying failures themselves, e.g.
CommentMarkdown.parse-reuse's CPU-heavy timeout, which is a separate PR. This change makes them visible instead of masked.Flag-off: test tooling only; no app code or shipped dependency changes.
ORCA_INTERNAL_WSL_HOSTSis irrelevant.User-risk: none. Vitest is a dev dependency.
Linked Issue
CI flake triage (unit shards blocking merges).
Visual Proof
N/A. Test tooling.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Reproduced locally: a scratch test throwing an error whose stack has
at map (native:1:11).Error: EISDIR … Tests (1), Errors 1 error.FAIL … Error: boom, Tests 1 failed (1).New
config/scripts/vitest-directory-frame-patch.test.mjs: checks the installed Vitest carries the file-only guard, so a Vitest upgrade that drops the patch fails loudly.patched-dependencies-frozen-install.test.mjs(the existing frozen-install hash check) passes, andpnpm install --frozen-lockfilesucceeds.Checks run:
pnpm tc,pnpm run typecheck:ci,pnpm run check:code-quality:changed, anti-slop oxlint, oxlint, ast-grep scan and gates.Review
Agent skill upstream boundary
Notes
The guard also covers any other frame whose name happens to match a top-level directory (
src:…,config:…).Status
Ready for review.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)