fix(extension): clamp Position character to avoid negative values#768
Merged
Conversation
Playwright reports error locations with column 0 when a stack frame has no column info (the fallback in playwright-core's stackTrace parser). The extension converted these via `column - 1`, producing -1, and VSCode's Position constructor throws "Illegal argument: character must be non-negative", surfacing as multiple uncaught errors on activation. Clamp `column - 1` the same way `line - 1` is already clamped, and update the Position mock to reject negatives so regressions are caught by the suite.
pavelfeldman
approved these changes
Apr 18, 2026
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.
Reference microsoft/playwright#40226
Summary
Users report the extension crashes with "Illegal argument: character must be non-negative" after a recent Windows update (25H2 / build 26200.8246), leaving no tests visible. The underlying trigger is a
connect ETIMEDOUT ::1:<port>when the extension fails to connect to its spawned Playwright test server (likely OS-level IPv6/loopback change). That's a separate root cause — this PR is about the crash that follows.When
listFiles()throws,TestModel._listFilessynthesizes a config error withlocation: { file: configFile, line: 0, column: 0 }. Downstream,TestTree._syncConfigErrors(andExtension._asPosition) didcolumn - 1without clamping — producingcharacter = -1, which VSCode'sPositionconstructor rejects. Six uncaught errors per activation, one per surfaced error location.column - 1the same wayline - 1was already clamped, at all three call sites that convert a Playwright error location into aPosition.Positionmock in tests to reject negative line/character (matching real VSCode behavior), so any future regression is caught by the suite.problems.spec.tscoveringcolumn = 0.The underlying ETIMEDOUT is not addressed here — this fix just keeps the extension usable (diagnostic is shown, tests remain discoverable) instead of crashing silently when it happens.