Skip to content

draft(crash-reporting): rebase the React #185 write-chain driver instrumentation onto main - #15736

Closed
nwparker wants to merge 3 commits into
mainfrom
nwparker/react185-driver-instrumentation
Closed

nwparker wants to merge 3 commits into
mainfrom
nwparker/react185-driver-instrumentation

Conversation

@nwparker

@nwparker nwparker commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​487 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​487
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​383 $\color{#cf222e}{\Huge{\mathbf{−}}}$​89 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​294

Draft. The rebase is clean and green, but adversarial review found blocking design issues in the capture policy itself. Opening this so the rebased branch and the analysis are not lost again — this is the tenth react185 branch, and the previous nine were abandoned without a written reason. Do not merge as-is.

Original work by @brennanb2025. All three commits cherry-picked with authorship intact; I added nothing to them.

Description

Orca's #orca-crashes channel has a standing cluster of React #185 ("Maximum update depth exceeded") crashes at boundary_id=terminal.workbench (×6) and boundary_id=page.activity (×2) in 1.4.184/1.4.185. During this week's triage, two independent investigations failed to reproduce or root-cause either one, and both concluded independently that the cluster cannot be closed by reasoning alone — the missing evidence is which store slice is writing on every commit before the nested-update limit trips. That is exactly what origin/react185-driver-instrumentation was built to capture, and it was never landed.

This branch rebases it onto current main.

What is verified

  • The three commits cherry-pick cleanly onto current main despite the source branch being 157 commits behind.
  • store-write-chain-telemetry + wiring + cross-store wiring + renderer-breadcrumb suites: 38 passed (38).
  • Full store suite: 281 files / 2778 tests passed.
  • tsc --noEmit on both config/tsconfig.node.json and config/tsconfig.web.json: exit 0.
  • Merges cleanly against fix(crash-reporting): scope renderer breadcrumbs to the renderer that emitted them #15709.

Why it is a draft: blocking findings

Four adversarial review loops (fresh reviewer each). It did not converge.

1. The capture floor is backwards — it would systematically miss the crash it exists to catch. (blocker)
The "deepest burst wins" rule assumes a #185 ring produces the deepest write chain. It doesn't: a ring's write depth is bounded by React's ~50-commit limit, while benign same-flush bulk writes are unbounded. So a routine bulk operation raises the bar and silently suppresses the capture for the ring that actually crashes.

2. Measured capture/IPC amplification that switches on exactly in the crash regime. (perf, measured)
Steady-state cost is genuinely fine — +2.6 ns/write in a burst, +27.4 ns/write isolated, zero added allocation, no effect on the selector fan-out benchmark. But a storm sweep found a cliff:

writes/flush= 49  ->  ipc sends/s=  3.0   stacks/s=  0.5
writes/flush= 50  ->  ipc sends/s=120.0   stacks/s= 60.0
writes/flush=300  ->  ipc sends/s=120.0   stacks/s= 60.0

At ≥50 writes/flush that is 60 stack captures/s inside the React commit phase (1.1 ms/s), ~740 KB/s structured-cloned renderer→main, and 2.2 ms/s of main-process CPU sanitizing — for zero additional evidence, because 30 s name-coalescing keeps one slot and the newest payload wins. ≥50 writes/flush is the #185 regime. It floods hardest precisely when the app is already dying.

3. In shipped builds the captured stack is largely unreadable. (major)
Vite's default esbuild minify renames function declarations, no keepNames or sourcemap is configured, and the crash sanitizer then strips file:line:col — so only object-property frames survive. The evidence is weakest in exactly the builds users run.

4. A storm can leave the report with zero write-chain evidence. (blocker)
Opting the write-chain crumb into 30 s name-coalescing means that once the owned ring slot is evicted, resolvePendingCoalescedBreadcrumb drops the pending payload rather than materializing it, discarding the newest, deepest, stack-bearing capture. The module's soundness contract — "absence of the breadcrumb rules out zustand-write-driven rings" — depends on that not happening, so absence currently cannot be trusted.

5. Always-on with no gate or kill switch, and on the web/paired client crashReports.recordBreadcrumb is () => {}, so that renderer pays the wrapper and every 40-frame new Error().stack capture and can never emit evidence. (minor)

6. The repo's own guard does not cover this. npm run check:zustand-selector-fanout builds a raw createStore from zustand/vanilla and never imports installSharedStoreWriteChainTelemetry, so it passing is not evidence the always-on setState wrapper is safe. (minor)

What I deliberately did not do

Review loops 2–4 produced eight remediation commits attempting to fix the above. I discarded them: they introduced a regression against origin/main affecting every coalesced breadcrumb (orphan views stealing snapshot budget that isCoalescedCrumbStillInEvidence still assumed was available), and crept into crash-breadcrumb-store.ts, creating both a textual conflict and a semantic incompatibility with #15709 — the synthesized orphan view carried no origin, reintroducing the cross-renderer attribution bug that PR exists to fix.

This branch is therefore Brennan's original three commits, unmodified, rebased and verified. The remediation attempts are recoverable from the workflow transcript if wanted, but they made it worse.

Suggested path

Findings 1 and 4 are policy bugs, not plumbing bugs — the capture criterion is wrong, independent of how it is wired. Worth deciding the criterion first (bound-aware rather than depth-ranked, and don't coalesce the payload that carries the stack), then rewiring. Finding 3 is cheap and independent: keepNames for the renderer build would make every future captured stack readable regardless of what else changes.

Related: #15709 (crash breadcrumb attribution), which is a prerequisite for trusting any breadcrumb-based evidence, including this one.

…tand store and budget for mixed rings

M1: running-terminal-close-confirm, plugin-panels, and plugin-language-packs
now install the same tracker as useAppStore — one depth counter and capture
budget, since a cascade can cross stores and per-store counters would each
idle under the threshold. The module header states the scope so an absent
breadcrumb stays readable: raw useSyncExternalStore subscriptions and pure
React-state rings remain uncovered.

M2: the depth-40 margin claim was one-directional — commits reach React's
limit no later than writes, so a mixed ring (store write + component-state
hop per cycle) threw before write 40 and captured nothing. Threshold is now
25: (1+k)*(T-1) <= 50 tolerates k=1 non-store commit per store write.
…gn capture inside the floor

A routine bulk tab close (8-12 tabs, >=2 writes each) crosses the 25-write
threshold in one flush; under first-capture-wins its stack occupied the
single coalesced ring slot for 10s, so a REAL #185-bound ring seconds later
recorded nothing and the crash blamed the bystander bulk close.

Inside a capture floor window, a burst now earns a capture only by running
strictly deeper than everything already recorded there (its stack is taken
live at that crossing), and every captured burst is upgraded at burst end
with its final depth - the discriminator between a benign batch (ends near
the threshold) and a true ring (runs toward React's limit of 50). Repeating
storms still cost one stack per window and one ring slot per 30s; the
below-threshold path stays allocation- and Error-free.
@nwparker

Copy link
Copy Markdown
Contributor Author

Closing — largely overtaken.

225 commits behind main, and #16153 (merged) already retired the dead end this instrumentation was built to solve: boundary_id on a React #185 report names a bystander, because React's nested-update counter is module-global and getRootForUpdatedFiber throws on the next setState from any fiber. Reports are now stamped attribution: unreliable.

Independent review also found the instrumentation would not do its job as written: the capture floor is backwards — a #185 ring's write depth is bounded by React's ~50-commit limit while benign bulk writes are unbounded, so routine work suppresses the capture that matters — and it floods at ≥50 writes/flush (60 stack captures/s, ~740 KB/s to main, 2.2 ms/s main CPU) for zero extra evidence, which is exactly the #185 regime.

Original work by @brennanb2025; the rebase and the review notes are preserved here if it is revisited.

@nwparker nwparker closed this Aug 26, 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.

2 participants