fix(ci): inject CodSpeed V8 flags via vitest execArgv#4
Merged
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
The `Benchmarks (CodSpeed)` job was failing with `SyntaxError: Unexpected token '%'` at `@codspeed/core/src/optimization.ts:10` (the V8 native `%OptimizeFunctionOnNextCall`). Root cause: @codspeed/vitest-plugin reads vitest's package.json to detect the major version and picks the v3 vs v4 `execArgv` injection path accordingly. Our pnpm override aliases `vitest` to `@voidzero-dev/vite-plus-test@0.1.18`, so the plugin sees major version 0 and falls back to the v3 path (`poolOptions.forks.execArgv`), which vitest 4 ignores. The `--allow-natives-syntax` V8 flag never reaches the benchmark worker. Fix: when CodSpeed is running (`CODSPEED_ENV` set by the action), resolve V8 flags from @codspeed/core ourselves and inject them into vitest 4's top-level `execArgv`. `NODE_OPTIONS=--allow-natives-syntax` is not a viable workaround — Node security-lists disallow that specific flag in NODE_OPTIONS. Credit: @codspeed-hq bot identified this root cause in the draft PR that we closed in favor of a human-authored commit.
e75758d to
ea43477
Compare
Congrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
3 tasks
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
The
Benchmarks (CodSpeed)job is failing withSyntaxError: Unexpected token '%'at@codspeed/core/src/optimization.ts:10(the V8 native%OptimizeFunctionOnNextCall).Root cause
@codspeed/vitest-pluginreads vitest'spackage.jsonto detect the major version and picks the v3 vs v4execArgvinjection path accordingly.Our
pnpm-workspace.yamloverrides aliasvitestto@voidzero-dev/vite-plus-test@0.1.18, so the plugin sees major version 0 and falls back to the v3 path (poolOptions.forks.execArgv) — which vitest 4 ignores. The--allow-natives-syntaxV8 flag never reaches the benchmark worker.Fix
When CodSpeed is running (detected via
CODSPEED_ENVwhich the action sets), resolve V8 flags from@codspeed/coreourselves and inject them into vitest 4's top-levelexecArgv.Considered alternatives
NODE_OPTIONS=--allow-natives-syntaxon the CI step — Node's NODE_OPTIONS allowlist explicitly blocks--allow-natives-syntax. Fails at runtime with--allow-natives-syntax is not allowed in NODE_OPTIONS.vitest bench --run— bypassesvpbut loses vite-plus's config resolution. Workable fallback if theexecArgvapproach regresses.Credit
The codspeed-hq bot correctly identified this root cause in a draft PR (#3). We closed that PR and re-authored the same fix here to keep contributors human.
Test plan
Benchmarks (CodSpeed)CI job completes successfullymainestablishes the CodSpeed baseline