fix(browser): fix error stacktrace location off-by-one#10724
Merged
hi-ogawa merged 10 commits intoJul 14, 2026
Conversation
…e map lookup `parseStacktrace` fed the browser's 1-based `error.stack` column straight into the source map lookup (0-based), then returned the mapped column without converting back. The off-by-one was normally masked by wide mapping segments, but oxc now emits a segment boundary for closing delimiters, so Safari (which anchors call frames at the open paren) could cross into the adjacent segment and drift, causing webkit-only column differences. Subtract 1 before the lookup and add 1 to the result, matching vite's SSR stack rewriter (`ssrStacktrace.ts`). Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
parseStacktrace + getSourceMap
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Re-baseline the non-browser suites affected by the parseStacktrace column fix (+1 on source-map-remapped stack columns): e2e stacktraces/reporters/ aria snapshots, coverage source-maps, and the UI trace editor cursor. Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
Re-baseline browser spec expectations after the parseStacktrace 1-based to 0-based column fix. Columns now resolve to the correct 1-based source position, so chromium/firefox shift by +1 and webkit converges onto the same source column across browsers. Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
After the stacktrace column fix, several browser-specific expectations resolve to the same source column. Collapse the webkit/else branches in playwright-trace-mark and remove the duplicated safari branch in the "logs have stack traces" runner test. Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
The non-rolldown webkit branches (nested under `if (rolldownVersion)`) were not exercised by the rolldown-vite run used to re-baseline, so they kept pre-fix columns and would fail the vite@7 CI job. Verified against a local `vite@7` (non-rolldown) run: they converge to the same source column as the rolldown/other-browser branches. Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
With the stacktrace column fix, the rolldown and non-rolldown stack columns resolve to the same source position, so the `if (rolldownVersion)` branches in aria-snapshot, errors, playwright-trace-mark and the runner timeout-hooks test are now redundant. Collapse them into a single snapshot each and drop the unused `rolldownVersion` imports. Verified on both rolldown-vite and vite@7 (non-rolldown) runs. Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
hi-ogawa
commented
Jul 8, 2026
Comment on lines
+264
to
+271
| if (stack.line <= 0 || stack.column <= 0) { | ||
| return stack | ||
| } | ||
| const position = getOriginalPosition(traceMap, { | ||
| line: stack.line, | ||
| // stacktrace's column is 1-indexed, but sourcemap's one is 0-indexed | ||
| column: stack.column - 1, | ||
| }) |
Collaborator
Author
There was a problem hiding this comment.
This is copied from Vite SSR stacktrace mapping
- https://github.com/vitejs/vite/blob/fdefbcfc2d0c6b9c12da91212f701cc1b58947de/packages/vite/src/node/ssr/ssrStacktrace.ts#L49-L56
- https://github.com/vitejs/vite/blob/fdefbcfc2d0c6b9c12da91212f701cc1b58947de/packages/vite/src/module-runner/sourcemap/interceptor.ts#L361-L369
AriPerkkio
reviewed
Jul 14, 2026
Co-authored-by: OpenCode <[email protected]>
AriPerkkio
approved these changes
Jul 14, 2026
Member
|
I'd recommend to merge this with title |
parseStacktrace + getSourceMap
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.
Description
While digging through #10723 (comment), apparently our
parseStacktrace + getSourceMapis the one with off-by-one column issue.Note that we do this combination of
parseStacktrace + getSourceMaponly for browser mode error mapping on the server and for external module error, so it may not be too surprising to discover this just now.For example,
After this change, many old branches of
isRolldown / webkitconverges with existing chrome/firefox column location, so test snapshots are unified. There are still remaining divergence for webkit but they look mostly cosmetic.📔 The summary of remaining differences
Helper calls
Chromium points at
await; Firefox/WebKit point at the helper call.Thrown errors
Chromium/Firefox point at
new; WebKit points atError.This pattern appears in:
error-in-dep/index.js:2failing/src/error.ts:8trace-mark/basic.test.ts:31Explicit stack
trace-mark/basic.test.ts:50Unhandled error
WebKit reports both
newandError; other browsers report onlynew.throw-unhandled-error.test.ts:9Bundled dependency
bundled-lib/src/b.js:2bundled-lib/src/index.js:5So the remaining difference is mostly semantic placement: Chromium/Firefox tend to identify the expression start, while WebKit often identifies the constructor identifier or call parenthesis.
TODO
parseStacktraceis also used for ViteforwardConsolehttps://vite.dev/config/server-options#server-forwardconsole. They need to update their test after the bump.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.