Skip to content

fix(vitest-plugin): explain a missing benchmark function - #109

Open
prisis wants to merge 1 commit into
CodSpeedHQ:mainfrom
prisis:fix/vitest-missing-bench-fn
Open

prisis wants to merge 1 commit into
CodSpeedHQ:mainfrom
prisis:fix/vitest-missing-bench-fn

Conversation

@prisis

@prisis prisis commented Oct 26, 2026

Copy link
Copy Markdown

Fixes #107.

When the benchmark file and the plugin resolve different copies of vitest (pnpm installs one per set of peers, e.g. one per vite major), the plugin reads an empty benchmark registry. The analysis runner then failed with a bare TypeError: fn is not a function. runAnalysisBench now checks the result of getBenchFn and, when it isn't a function, throws an error that names the benchmark, the likely cause and the fix.

This doesn't change which vitest the runner imports. That's the larger change discussed in the issue.

Test

should explain a benchmark function it cannot find makes getBenchFn return undefined and asserts the new message. It fails on main with fn is not a function. lint, typecheck, format and the plugin's 15 tests pass.

🤖 Generated with Claude Code

When the benchmark file and the plugin resolve different copies of
vitest (pnpm installs one per set of peers, e.g. one per vite major),
the plugin reads an empty benchmark registry and the analysis runner
failed with a bare "TypeError: fn is not a function". Throw an error
that names the benchmark, the likely cause and the fix instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

The legacy Vitest analysis runner now explains why it cannot find a benchmark function instead of failing with fn is not a function.

  • The analysis runner explains when a benchmark function is missing.

Reviews (1) · Last reviewed commit: "fix(vitest-plugin): explain a missing be..." · Reviewed by Greptile

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.

vitest-plugin: "fn is not a function" when the plugin resolves a different vitest copy than the benchmarks

1 participant