Repository navigation
fix(browser): stop reporting runtime SyntaxErrors as caller syntax errors - #358
Merged
ankitranjan7 merged 1 commit intoAug 19, 2026
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. |
ankitranjan7
force-pushed
the
fix/browser-run-syntax-position
branch
from
August 19, 2026 05:59
e9e3ae2 to
3997e54
Compare
…rors 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>
ankitranjan7
force-pushed
the
fix/browser-run-runtime-syntax-classification
branch
from
August 19, 2026 06:00
bbc459a to
ac9a130
Compare
ankitranjan7
merged commit Aug 19, 2026
5d1b08f
into
fix/browser-run-syntax-position
36 checks passed
ankitranjan7
pushed a commit
that referenced
this pull request
Aug 19, 2026
…pile errors (#356) * fix(browser): report the caller's line and column for browser-run compile 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> * fix(browser): stop reporting runtime SyntaxErrors as caller syntax errors (#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> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
ankitranjan7
deleted the
fix/browser-run-runtime-syntax-classification
branch
September 1, 2026 12:42
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 #355
Stacked on #356 (
fix/browser-run-syntax-position) — merge that one first; this PR targets its branch and only makes sense on top of it.What was wrong
normalizeExecutionErrorclassified by error name:That matches any
SyntaxErrorreaching the host.JSON.parseon malformed input throws one, so a program with no syntax error at all was reported as having one, with a hint sending the reader to audit correct code.What changed, and why this option
The branch is deleted, not rewritten.
#356 makes a genuine compile failure tag itself where it happens: the bootstrap catches the error from
new AsyncFunction(source)and throws withcode = 'BROWSER_RUN_SYNTAX_ERROR'plus line/column/excerpt/hint, which the earliercode.startsWith('BROWSER_RUN_')branch returns untouched. So the regex is now only ever reached bySyntaxErrors that are not compile failures of the caller's program — runtime ones.Runtime
TypeErrors andRangeErrors already fall through to the generic normalized error (errorCode: runtime_command_failedon the wire). Keeping a special branch for runtimeSyntaxError— under any code or hint — would preserve exactly the arbitrariness the issue is about: an error singled out for special treatment because of its name rather than its origin. There is also no honest code for it inBrowserRunErrorCode, and inventing one that fires only forSyntaxErrorwould be a new inconsistency, not a fix. Deleting the branch makes origin, not name, the classifier: compile failure →BROWSER_RUN_SYNTAX_ERRORwith position; everything else → treated as the runtime error it is.The runner-level error keeps its own identity (
name === 'SyntaxError', original message). The daemon wire dropsnameand thedetailspayload for all uncoded runtime errors — pre-existing behaviour for every runtimeTypeErrortoday, deliberately not widened here.Before / after
Verified against a daemon restarted from this branch (
npx tsx src/main.ts daemon restart→ v0.7.2).1. Genuine compile error — unchanged, still positioned (
const a = 1;/const s = 'x'y';/return a;):2. Runtime
JSON.parsefailure (return JSON.parse('1,2,3');):before
after
which is identical in shape to how a runtime
TypeErrorreports today, confirmed in the same session:The underlying
response.json()bug (#354) is out of scope here and untouched.Tests
Extended #356's block in
src/browser/run/runner.test.tsrather than duplicating it: its compile-error test now asserts through a sharedrunErrorhelper, and a new case assertsJSON.parse('1,2,3')yields noBROWSER_RUN_*code, no hint, and keepsname === 'SyntaxError'.npx vitest run --project unit: 117 failing tests across 7 files, identical to the #356 baseline measured before the edit (all inhosted/*and plugin-manifest suites plus the knowndoctorprofile-display failure — none touch browser-run).src/browser/run/runner.test.tspasses 75/75.npx tsc --noEmit: clean. The 5 pre-existing errors were #356's new test indexing aBrowserRunResult | Errorunion off.catch(); therunErrorhelper types that away, which is why they are gone rather than carried forward.Nothing else depended on the old behaviour
Grepped
BROWSER_RUN_SYNTAX_ERROR,SyntaxError, and the removed hint string acrosssrc/,skills/,plugins/, and docs. The only references were the code itself, theBrowserRunErrorCodeunion (unchanged — the code is still produced by the compile path), and #356's test.skills/webcmd-browser/references/browser-run-playwright.mddescribesBROWSER_RUN_*errors only in the aggregate and never documented syntax-error classification, so it needs no update.🤖 Generated with Claude Code