error: don't double source-map rethrown frames after reading .stack - #36726
error: don't double source-map rethrown frames after reading .stack#36726robobun wants to merge 3 commits into
Conversation
When user code reads error.stack and then rethrows, JSC clears
m_stackTrace after materializing the string. The uncaught-exception
printer then falls back to parsing the .stack string via
V8StackTraceIterator, which sets remapped=true on every parsed frame
because the positions in the string are already source-mapped.
remap_zig_exception checked that flag for the top frame but not for the
rest, so every non-top frame was fed back through resolve_source_mapping
and remapped a second time, producing wrong line numbers.
Also teach V8StackTraceIterator to parse V8-style frames with no
function name ("at /path:line:col"), which it previously treated as
end-of-stack, so the anonymous top-level frame is no longer dropped.
Fixes #15859
|
Duplicate of #36602, which already includes both changes needed for #15859 (the |
|
Warning Review limit reached
Next review available in: 4 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
Comment |
| // /path/to/file.js:1:2 | ||
| // async /path/to/file.js:1:2 |
There was a problem hiding this comment.
If you need a paragraph-long comment to justify why the workaround is OK, the code is wrong — fix the code
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
|
Closing as duplicate of #36602. |
Fixes #15859.
Repro
Before:
After (matches
error.stack):Cause
Reading
error.stackcauses JSC to clearm_stackTraceafter materializing the string. On the rethrow,fromErrorInstancehas no liveStackFramevector and falls back to parsing the.stackstring withV8StackTraceIterator, which setsremapped = trueon every parsed frame (the positions are already source-mapped).remap_zig_exceptionchecked that flag for the top frame but not in the loop over the remaining frames, so each non-top frame was fed back throughresolve_source_mappingand remapped a second time. With three unused imports stripped by the transpiler, source line 8 is generated line 5; remapping source 8 as if it were generated yields source 13.Separately,
V8StackTraceIteratortreated a line of the format /path:line:col(no function name, no parentheses) as end-of-stack, dropping the anonymous top-level frame.Fix
remap_zig_exception: skip frames withremapped == truein the non-top loop (matching the top-frame check andremap_stack_frame_positions).V8StackTraceIterator::parseFrame: when no parentheses are present, parse the whole line assourceURL:line:colwith an empty function name (handlesat <url>:<l>:<c>andat async <url>:<l>:<c>).Verification
test/regression/issue/15859.test.tshas three cases (wrong-line, dropped frame, printed-frames-match-error.stack). All three fail on 1.4.0-canary.1+1498d7b77 and pass with this change.