fix(module-runner): prevent crash on negative column in stacktrace#21585
Open
AriPerkkio wants to merge 2 commits intovitejs:mainfrom
Open
fix(module-runner): prevent crash on negative column in stacktrace#21585AriPerkkio wants to merge 2 commits intovitejs:mainfrom
AriPerkkio wants to merge 2 commits intovitejs:mainfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
7 tasks
| const line = frame.getLineNumber() as number | ||
| const column = (frame.getColumnNumber() as number) - 1 | ||
| const line = frame.getLineNumber() ?? 0 | ||
| const column = (frame.getColumnNumber() ?? 1) - 1 |
Contributor
There was a problem hiding this comment.
The fix does not prevent negative columns in all cases. When getColumnNumber() returns 0 (a valid non-nullish value), the result is still -1 because the nullish coalescing operator (??) only handles null or undefined, not 0. This means negative columns can still occur, contradicting the PR's stated purpose.
To actually prevent negative columns, the code should be:
const column = Math.max(0, (frame.getColumnNumber() ?? 1) - 1)
Suggested change
| const column = (frame.getColumnNumber() ?? 1) - 1 | |
| const column = Math.max(0, (frame.getColumnNumber() ?? 1) - 1) |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
AriPerkkio
commented
Feb 7, 2026
Comment on lines
+190
to
+191
| // Without the fix this causes unhandler error that cannot be caught inside the test case | ||
| await runner.import('/fixtures/a.ts') |
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.

ModuleRunnercrashing when negative columns in stacktraces #21587On Vite's side the root cause is
as number, asCallSitecan returnnullin line/col.