Skip to content

fix(test): Vitest reports a failure whose stack names a Bun builtin - #35384

Merged
nwparker merged 1 commit into
mainfrom
nwparker/vitest-stack-dir-frames
Oct 28, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/vitest-stack-dir-frames

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15

ELI5

Unit shards sometimes failed with a confusing EISDIR: illegal operation on a directory from inside Vitest, instead of naming the test that actually failed. Tests run under Bun, and Bun labels its built-in functions native in error stacks. Vitest took native for a file, found our repo's native/ 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:

After: the same failure is reported as a normal failing test, with its real error.

Mechanism:

  • A one-line pnpm patch to [email protected] (config/patches/[email protected]). The getSourceMap hook in TestRun.syncUpdateStacks now also requires statSync(file).isFile() before readFileSync.
  • Vitest parses native:1:11 as the path native, which resolves against the repo root. It existed (native/ holds our native modules), so it was read.
  • Registered in pnpm-workspace.yaml patchedDependencies.
  • The lockfile change is just the patch hash, plus 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: onStackTrace runs after the source-map read.

Alternatives considered:

  • Renaming native/ would touch build and packaging.
  • Rewriting Bun's stack format in a setup file would change every test's error output.

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_HOSTS is 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).

    • Before: Error: EISDIR … Tests (1), Errors 1 error.
    • After: FAIL … Error: boom, Tests 1 failed (1).
    • The scratch file isn't committed.
  • 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, and pnpm install --frozen-lockfile succeeds.

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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The guard also covers any other frame whose name happens to match a top-level directory (src:…, config:…).

Status

Ready for review.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

Patches Vitest’s error reporting to skip directories when reading source maps.

  • Vitest skips directory paths when it looks for source maps.

Reviews (1) · Last reviewed commit: "fix(test): report a failing test whose s..." · Reviewed by Greptile

@nwparker

Copy link
Copy Markdown
Contributor Author

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.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66dbd232-a920-41b7-a038-94a61868fd56
Commits

Reviewing files that changed from the base of the PR and between c66d873 and 8bfad4b.

Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 3
  • config/patches/[email protected]
  • config/scripts/vitest-directory-frame-patch.test.mjs
  • pnpm-workspace.yaml

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

The workspace now applies a patch to Vitest 5.0.5. When no transform result exists, the patch reads a source map only if the path exists and is a regular file. A test checks that Vitest’s cli-api chunk contains this guard.

Priority: Normal

Merge Risk: Minimal · up to 8bfad

The Vitest patch is applied consistently and prevents directory paths from being read as source files; no concrete merge-blocking risk remains.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description follows the template well. It has ELI5, What Changed (before/after and mechanism), Why (with alternatives), Linked Issue, Visual Proof (N/A with reason), Testing (manual reproduction a… Add a real linked issue number in the 'Fixes #' line. Replace the 'CI flake triage' note with an actual issue or a justification the maintainers accept. Fill in the AI Disclosure section or mark it as not applicable for internal contributor…
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names a Vitest failure whose stack contains a Bun builtin frame. The change adds a file-only guard (statSync(file).isFile()) to Vitest's getSourceMap hook via a pnpm patch, so Vitest reports…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names a Vitest failure whose stack contains a Bun builtin frame. The change adds a file-only guard (statSync(file).isFile()) to Vitest's getSourceMap hook via a pnpm patch, so Vitest reports the real failing test instead of an EISDIR error. The title is specific and matches the main change. It uses the fix(test) prefix and is short, but it does not name the mechanism (the file-only guard on source-map reads).

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (2 skipped: 2 unsupported.)

Full details: Description check

Explanation

The description follows the template well. It has ELI5, What Changed (before/after and mechanism), Why (with alternatives), Linked Issue, Visual Proof (N/A with reason), Testing (manual reproduction and a new automated guard test), Review and upstream boundary sections, Notes, and a Checklist. Gaps: the Linked Issue section reads 'Fixes #' with no issue number, and only a 'CI flake triage' note is given instead of an actual issue link, which the template says is required for outside contributors. The AI Disclosure section is blank. The Status section is not in the template. The final checklist item for pnpm lint/typecheck/test/build is unchecked. The Testing section lists some checks but does not confirm the full pnpm test suite passed.

Resolution

Add a real linked issue number in the 'Fixes #' line. Replace the 'CI flake triage' note with an actual issue or a justification the maintainers accept. Fill in the AI Disclosure section or mark it as not applicable for internal contributors. Confirm whether pnpm lint, typecheck, test, and build pass, and check that item or explain why CI will cover it.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit f12e12f into main Oct 28, 2026
96 of 98 checks passed
@nwparker nwparker mentioned this pull request Nov 20, 2026
11 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant