Skip to content

DOMException: inherit from ErrorInstance for [[ErrorData]] and .stack - #32898

Open
robobun wants to merge 12 commits into
mainfrom
farm/c00f6fd2/domexception-error-instance
Open

DOMException: inherit from ErrorInstance for [[ErrorData]] and .stack#32898
robobun wants to merge 12 commits into
mainfrom
farm/c00f6fd2/domexception-error-instance

structuredClone: round-trip a DOMException's stack; put the header st…

0c69732
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Aug 11, 2026 in 44m 54s

Code review found 3 potential issues

Found 4 candidates, confirmed 3. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 3
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/jsc/bindings/webcore/JSDOMException.cpp:258-261 putHeaderStackIfNoFrames emits leading ": " when name is empty
🟡 Nit src/jsc/bindings/webcore/JSDOMException.cpp:246-249 setStackString leaves m_stackTrace populated, visitChildren roots stale deserialize-site frames

Annotations

Check warning on line 261 in src/jsc/bindings/webcore/JSDOMException.cpp

See this annotation in the file changed.

@claude claude / Claude Code Review

putHeaderStackIfNoFrames emits leading ": " when name is empty

The header-only `.stack` fallback guards empty *message* but not empty *name*, so `new DOMException("boom", "")` with no captured frames yields `.stack === ": boom"` — a leading colon-space with no name — while the framed path via `formatStackTrace` (FormatStackTraceForJS.cpp:155-162) correctly emits just `"boom"`. The identical one-sided guard is at `retrieveErrorMessage` (JSDOMExceptionHandling.cpp:108). Mirror `formatStackTrace`'s two-sided guard at both sites, e.g. `name.isEmpty() ? message 

Check warning on line 249 in src/jsc/bindings/webcore/JSDOMException.cpp

See this annotation in the file changed.

@claude claude / Claude Code Review

setStackString leaves m_stackTrace populated, visitChildren roots stale deserialize-site frames

`setStackString()` puts the round-tripped stack and flips `m_errorInfoMaterialized`, but leaves the deserialize-site `m_stackTrace` populated — so `visitChildrenImpl` keeps rooting those callees/CodeBlocks on every GC for the clone's lifetime even though nothing will ever consult them. Add `setStackFrames(vm, {})` here (the same drop `errorInstanceLazyStackCustomGetter` does after materializing) so the vector is empty and `visitChildren` roots nothing.