fix(browser): report the caller's line and column for browser-run compile errors - #356
Merged
Merged
Conversation
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. Limitations
This review is advisory and does not block merging. |
…pile errors A program that fails to compile was surfaced as "QuickJS promise rejected: invalid number literal" with no position, because new AsyncFunction(source) runs inside the promise and its SyntaxError carried lineNumber/columnNumber that were then discarded. The prefix pointed at async plumbing rather than the program, so readers hunted heredocs and await instead of the actual defect: an unescaped quote in a string literal holding a URL. Compile the program before racing it, and turn a compile failure into a BROWSER_RUN_SYNTAX_ERROR carrying the caller's own line and column (the AsyncFunction wrapper adds two lines, so subtract them), a windowed excerpt with a caret, and a hint naming the quoting cause. Errors that already carry a BROWSER_RUN_ code keep their message instead of gaining a host stage prefix. runner.test.ts imported MemorySnapshotBaselineStore twice, so the file failed to load and its 74 tests never ran; the duplicate is removed here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ankitranjan7
force-pushed
the
fix/browser-run-syntax-position
branch
from
August 19, 2026 05:59
e9e3ae2 to
3997e54
Compare
…rors (#358) normalizeExecutionError matched /syntaxerror/i against any error reaching the host, so a runtime JSON.parse failure in a perfectly valid program was reported as BROWSER_RUN_SYNTAX_ERROR with a hint telling the reader to fix correct code. Since compile failures now tag themselves at the point of compilation, the only SyntaxErrors reaching this classifier are runtime ones. Drop the branch: a runtime SyntaxError keeps its own name and message, exactly like the runtime TypeErrors and RangeErrors that already flow through the generic path. Closes #355 Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #353.
A program that fails to compile inside
browser runwas reported asQuickJS promise rejected: invalid number literalwith no position. The prefixpointed at async plumbing rather than at the program, so readers audited
heredocs and
awaitinstead of the actual defect — an unescaped quote in astring literal holding a URL.
Before / after
Real case from the task eval, a 2,361-character line:
What changed
rejected promise wearing a host stage prefix.
new AsyncFunction(body)prepends twolines of wrapper, so those are subtracted — verified against QuickJS, which does
supply
lineNumber/columnNumber; they were simply being discarded.quickjs-host.ts#toErrorno longer prefixes errors that already carry aBROWSER_RUN_code.Drive-by
runner.test.tsimportedMemorySnapshotBaselineStoretwice, so the file failedto load and its 74 tests had never run. The duplicate is removed here; all 74
pass.
Verification
output for both the minimal case and the real 2,361-character program.
hint — this also pins the
AsyncFunctiontwo-line offset against futurequickjs-ng upgrades.
mainand unrelated(profile display,
personal: connected v1.2.3). Baseline onmainis 2460passing, so this adds 74 previously-dead tests.
🤖 Generated with Claude Code