Skip to content

fix(crash-reporting): stamp React #185 boundary attribution as unreliable - #16153

Merged
nwparker merged 1 commit into
mainfrom
nwparker/react185-attribution-unreliable
Aug 23, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/react185-attribution-unreliable

Conversation

@nwparker

@nwparker nwparker commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​294 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​294
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​91 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​90

Description

boundary_id and component_stack on a React #185 crash report name a bystander, not the component that is looping. This PR stamps those reports so triage stops clustering on a field that cannot carry that meaning.

React 19.2.7's infinite-update detector is a module-global counter, not per-fiber state:

  • commitRootImpl (react-dom-client.development.js:18325-18332) increments nestedUpdateCount when a commit leaves sync-ish lanes (remainingLanes & 42) pending on the root — and Orca has one root. Otherwise it resets to 0.
  • getRootForUpdatedFiber (:4619-4633) throws "Maximum update depth exceeded" once the counter passes NESTED_UPDATE_LIMIT (50, :27373). That function runs on every enqueueConcurrentHookUpdate — i.e. on the next setState from any fiber anywhere in the tree.

So once one runaway commit-phase loop pushes the counter past 50, the throw is delivered to whichever fiber calls setState next, and is caught by that fiber's nearest boundary. All eight #185 reports in the 1.4.188 batch begin getRootForUpdatedFiber → enqueueConcurrentHookUpdate → dispatchSetStateInternal → dispatchSetState. None of them shows the loop.

This was demonstrated, not argued: a test that flips two sibling subtrees changes the reported boundary_id with nothing else about the bug changed.

Why this matters

Triage has been clustering #185 by boundary_id for months. That produced the apparent "2 → 5 boundaries in 1.4.188" spread, which read as a regression — it isn't. Under a bystander model, going from ~2 samples to 8 predicts more distinct boundaries on its own, and no supporting code change was found (the boundary-id inventory, the victim components, and the useLayoutEffect/flushSync call-site count are all unchanged across the range).

It also means prior narrowing — "SortableTab's own fiber", "the TerminalPane fiber" — named bystanders.

Fix evidence

Tests written first, implementation absent:

FAIL src/main/ipc/...-attribution.test.ts > stamps unreliable attribution plus a human-readable note
  AssertionError: expected undefined to be 'unreliable'
FAIL ... > surfaces the caveat in the formatted report text a human reads
  expected '[Crash Report]...' to contain 'Attribution: unreliable'
FAIL ... > stamps the minified production #185 digest as unreliable attribution
FAIL ... > stamps the development "Maximum update depth exceeded" message as unreliable
Test Files  4 failed (4)      Tests  5 failed | 6 passed (11)

After — 31 files / 282 tests passed across the error boundaries, react-error-boundary-reporting, crash-reporting (main + shared), and the crash-report UI. tsc clean on both tsconfig.node.json and tsconfig.web.json; oxlint zero warnings; oxfmt --check clean.

A #185 report now formats with the caveat above the Details block, so a Slack reader hits it first:

[Crash Report]
...
Attribution: unreliable
React #185: the throw lands on whichever component called setState next after a
root-global counter tripped, so boundary_id and component_stack name a bystander.
Do not cluster these reports by boundary_id.

Details:
- boundary_id: page.automations        <-- left intact for continuity
- attribution: unreliable
- attribution_note: React #185: the throw lands on ...

ELI5

A factory has one alarm that counts how many times work bounced back in a row. When the count hits 50 the alarm fires — but it fires at whoever touches a machine next, not at the machine causing the bounces.

We've been reading the alarm log as "this machine is broken" and sending engineers to five different machines. Those five were just whoever happened to reach for a lever at the wrong moment.

This change doesn't find the broken machine. It stamps the log with "this name is whoever was standing nearby — don't dispatch on it," so nobody spends another month investigating bystanders.

Trade-offs

  • This does not fix the loop. The driver is still unidentified. This is a diagnosability change; the underlying fix: improve scrollbar and file explorer scroll behavior #185 crashes continue until the driver is found.
  • boundary_id is deliberately left populated rather than nulled, for continuity with historical reports and existing dashboards. A reader who ignores the new caveat can still be misled — mitigated by putting the caveat above the Details block.
  • Detection is by error identity, narrowly. One regex matches Minified React error #185, errors/185, invariant=185 (legacy decoder URL) and the dev text, with each numeric form guarded by (?!\d) so #1850/#1852/#18 don't match and other React numbers (#310) never do. It reads the message off Error instances, bare strings, and any object with a string message, so a non-Error throwable still classifies.
  • Wire compatibility (docs/reference/remote-wire-compatibility.md): new optional field only. attribution?: 'unreliable' on the renderer→main IPC args plus two optional detail keys. Nothing removed or repurposed; absent degrades exactly to today's behavior. The main normalizer emits attribution only when the value is literally 'unreliable', so a future renderer sending a different verdict degrades to no attribution rather than being trusted. The note text is main-generated from a shared constant, not trusted from the renderer, and goes through sanitizeCrashReportDetails under the 240-char cap so it can't be truncated mid-sentence.
  • No max-lines disable. Adding the formatter inline pushed crash-reporting.ts to 314 counted lines (cap 300), so the caveat formatter was extracted to crash-report-attribution-lines.ts, mirroring the existing crash-report-signature-lines.ts.

Adversarial review

Clean after 2 loops.

  • Loop 1 — 1 major, 2 minor. Major: the stamp was applied in only one boundary class, so reports from the second reporting boundary were unstamped. Fixed.
  • Loop 2 — clean. Three residual minors, deliberately left: getRendererErrorReportKey still keys dedupe on boundaryId (correct — dedupe should stay per-boundary even when attribution is unreliable); formatSummary still asserts a React-render summary; and main accepts the renderer's attribution without independent validation (bounded to the single literal 'unreliable', and the note is main-generated).

Perf

/perf: no meaningful impact, no changes applied. One regex on an already-fatal error path.

Follow-up

The corrected search space for the actual driver: it must leave sync-ish lanes pending on every commit — layout effects, ref callbacks, render-phase setState, and passive effects that write a useSyncExternalStore/zustand store (forceStoreRerender schedules at SyncLane, and commitRootImpl flushes passive effects synchronously before sampling remainingLanes). That last case matters here: zustand v5 is used in 95 renderer files. Event/IPC-driven churn is excluded — each event's commit is its own settled turn.

Related: #15736 (draft) would name the store slice writing on every commit.

A triager opening a "Maximum update depth exceeded" (minified React #185)
crash report sees a boundary_id and a component_stack that look like a
precise culprit, and treats them as one. They aren't. React's nested-update
counter is global to the root, not per fiber, so the invariant throws on
whichever component happens to call setState next after the counter trips.
The boundary that catches it is a bystander picked by commit order.

The visible cost is misrouting: identical crashes fan out across many
boundary_ids, so clustering the reports by boundary_id splits one bug into
several phantom ones, and each one points at innocent code.

The renderer now tags these reports with attribution: unreliable, and the
formatted report prints the caveat above the details blob where it can't be
scrolled past. Detection covers minified (#185), unminified, and errors/185
URL forms while rejecting #1850+.

Wire compatibility: attribution is a new optional field. Old hosts ignore
it; the host accepts only the one known verdict and drops anything else a
newer renderer sends, so no report is rejected on version skew.
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 11 minutes.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: abdae6dc-4955-4d03-8c83-65814a7762bd

📥 Commits

Reviewing files that changed from the base of the PR and between fe6f942 and f9dc2e1.

📒 Files selected for processing (9)
  • src/main/ipc/crash-reporting-renderer-error-report-attribution.test.ts
  • src/main/ipc/crash-reporting-renderer-error-report.ts
  • src/renderer/src/components/error-boundaries/react-185-bystander-attribution.test.tsx
  • src/renderer/src/lib/react-error-boundary-reporting.test.ts
  • src/renderer/src/lib/react-error-boundary-reporting.ts
  • src/shared/crash-report-attribution-lines.ts
  • src/shared/crash-reporting.ts
  • src/shared/react-update-depth-attribution.test.ts
  • src/shared/react-update-depth-attribution.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 0753f0a into main Aug 23, 2026
45 of 46 checks passed
@nwparker
nwparker deleted the nwparker/react185-attribution-unreliable branch August 23, 2026 22:56
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 25, 2026
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant