Commit 44f1c5f
fix(browser): report the caller's line and column for browser-run compile 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>1 parent f599e7c commit 44f1c5f
3 files changed
Lines changed: 66 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
601 | 601 | | |
602 | 602 | | |
603 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
604 | 607 | | |
605 | 608 | | |
606 | 609 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
58 | 67 | | |
59 | 68 | | |
60 | 69 | | |
| |||
231 | 240 | | |
232 | 241 | | |
233 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
234 | 263 | | |
235 | 264 | | |
236 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
| |||
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
125 | 121 | | |
126 | 122 | | |
127 | 123 | | |
| |||
489 | 485 | | |
490 | 486 | | |
491 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
492 | 511 | | |
493 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
494 | 519 | | |
495 | 520 | | |
496 | 521 | | |
497 | 522 | | |
498 | 523 | | |
499 | | - | |
| 524 | + | |
500 | 525 | | |
501 | 526 | | |
502 | 527 | | |
| |||
0 commit comments