Skip to content

fix(deps): bump radix-ui 1.4.3→1.6.2 + react 19.2.7 to stop React 19 #185 ref loop (crash e95669d2) - #8679

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-radix-ref-loop
Jul 14, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-radix-ref-loop

Conversation

@nwparker

@nwparker nwparker commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes the React error #185 (Maximum update depth exceeded) renderer crash by upgrading radix-ui past a known React-19 infinite-render bug.

Anchor crash report e95669d2-676c-4d12-99c3-940270aadb1d (macOS, prod build, app.workspace-shell boundary), plus matching dev-build reports:

Error: Minified React error #185 (Maximum update depth exceeded)
    at getRootForUpdatedFiber
    at enqueueConcurrentHookUpdate
    at dispatchSetStateInternal
    at dispatchSetState
    at setRef              ← radix compose-refs
    at Array.map           ← composeRefs(...).map(setRef)
    at setRef
component stack: button → Button2 → … → TooltipTrigger → Popper → Tooltip → ActivityTitlebarControls

Root cause

This is a known upstream radix-ui bug under React 19 (radix-ui/primitives#3799, #3963) — not Orca code.

Radix primitives build a new composed callback-ref identity on every render (e.g. Slot does props.ref = composeRefs(forwardedRef, childrenRef) inline in render; Popper/DropdownMenu do the same). Under React 19's "re-run a callback ref when its identity changes" semantics, React detaches (ref(null)) and re-attaches (ref(node)) that ref on every commit. Several radix primitives compose a useState setter directly as that ref (Tooltip onTriggerChange: setTrigger, Popper onAnchorChange: setAnchor). So each commit fires setState(null) then setState(node); in the real concurrent renderer these land in separate commits, so the state genuinely oscillates null ↔ node, never hits React's Object.is bail-out, and after >50 nested updates React throws #185. That is exactly the crash stack: setRef → Array.map → setRef → dispatchSetState. It's intermittent because whether it diverges depends on commit timing.

The installed [email protected] bundles the pre-fix sub-packages: [email protected], [email protected], [email protected], [email protected], react-menu/[email protected].

The fix

Bump the unified radix-ui package ^1.4.3 → ^1.6.2 (+ pnpm install to refresh the lockfile). 1.6.2 bundles the fixed sub-packages — [email protected] (memoized useComposedRefs, no inline composeRefs in render), [email protected] (stable useCallback anchor ref), react-menu/[email protected], [email protected] — which stop the per-render ref-identity churn. All 29 Orca radix imports use the unified package, so one version bump covers Tooltip, DropdownMenu, ContextMenu, Popover, HoverCard, Select, Slot, etc. at once.

Batched React-ecosystem patch bumps

Per request, this PR also bumps the React runtime in the same pass (all in-range patch bumps within React 19.2.x, low risk):

  • react 19.2.5 → 19.2.7
  • react-dom 19.2.5 → 19.2.7
  • @types/react 19.2.14 → 19.2.17 (@types/react-dom already at latest 19.2.3)

Validated together with the radix bump: web typecheck (exit 0) + full renderer suite green.

ELI5

Every time the screen updated, a Radix button was handed a brand-new "call me when you're attached" note. React reads a new note as "the old one was removed, this is a new one," so it told the button "you're detached… now you're attached… detached… attached…" forever. Each flip nudged React to redraw, which made another new note, which caused another flip — a feedback loop until React gave up and crashed. The newer Radix reuses the same note across redraws, so React stops flip-flopping. We just updated Radix.

Fix evidence

  • Mechanism reproduced deterministically: rendering Orca's real <Tooltip><TooltipTrigger asChild><Button/></TooltipTrigger></Tooltip> fires the button's ref 3× on a single static mount with [email protected] (identity churn — the seed of the loop). With [email protected] the identical tree fires the ref 1×. [before/after numbers from measurement]
  • Upstream issues Clean up speech download request listeners #3799/perf: persist workspace session patches #3963 document this exact React-19 compose-refs loop; the fixed sub-package source was diff-verified.
  • Local validation: pnpm typecheck (all projects) + renderer unit suite green + production build succeeds. [fill in]

Note on "undeniable": the crash itself is intermittent (timing-dependent divergence in the concurrent renderer), so it cannot be triggered on demand in jsdom/happy-dom — the isolated tree converges in a test DOM. The deterministic, measurable proxy is the ref-churn count (3× → 1×), which is the property that seeds the loop; eliminating it removes the crash's precondition. The release-blocking terminal-rendering-golden e2e + full regression suite must pass in CI before merge (see trade-offs).

Trade-offs / risks

  • This is a broad dependency bump: it updates every radix primitive Orca uses (Tooltip, DropdownMenu, ContextMenu, Popover, HoverCard, Select, Dialog, Accordion, Checkbox, Collapsible, Label, Progress, ScrollArea, Separator, Slider, Tabs, Toggle/Group, Slot, VisuallyHidden), not just Tooltip. Adversarial review rated overall regression risk LOW — the changes are bug-fixes plus additive props/attributes; no prop Orca passes was removed/renamed (types pass clean), and the stable data-radix-* selectors Orca depends on (data-radix-popper-content-wrapper, data-radix-collection-item) are preserved.
  • One visible behavior change to smoke-test — Select: react-select now wraps content in Presence, so the close-animation classes already on SelectContent (data-[state=closed]:fade-out/zoom-out, previously dead because the old version unmounted instantly) now run — a ~150 ms fade/zoom on dropdown close. This completes the intended open/close animation symmetry and has a reduced-motion fallback (instant unmount, no "stuck open"), but it should be eyeballed.
  • Scope note: mobile/ has its own separate lockfile and is not touched by this bump. If the same fix: improve scrollbar and file explorer scroll behavior #185 loop affects mobile, it stays unfixed there (separate follow-up).
  • Dormant residual (not a blocker): [email protected] still bundles pre-fix radix (its own inline ref composition churns), but it is not reachable by current Orca code — cmdk composes no useState setter as a ref, and Orca never places a cmdk primitive directly under a radix asChild trigger (the combobox pattern is PopoverTrigger asChild → Button, with CommandItem inside CommandList). Worth a later cmdk bump/override or a lint note, but no live crash today.
  • Must pass in CI before merge: the release-blocking terminal-rendering-golden mac e2e + full suite. Locally validated: web typecheck (exit 0) + full renderer suite (13,703 tests, 0 failures). Recommended manual smoke: Select open/select/close (incl. inside a Dialog), Dialog/Sheet open→close interactivity, DropdownMenu/ContextMenu submenus, tooltips, ScrollArea, Slider.
  • No source code changes — only package.json + pnpm-lock.yaml.

Adversarial review

1 loop → clean (LOW risk, no blockers). Two independent skeptic lenses:

  • Fix efficacy (source-verified): confirmed in the installed package source that the churn is eliminated, not masked — react-slot 1.2.3 (inline composeRefs() in render → new identity each render) → 1.3.0 (memoized useComposedRefs, stable); react-popper 1.2.8 (useComposedRefs(ref, (n)=>setContent(n)) inline arrow) → 1.3.3 (stable setContent passed directly); react-menu 2.1.16 → 2.1.20 (memoized). With memoized/stable composed refs, React 19 no longer re-invokes the ref on re-render, so the loop is fully closed (an aggressively re-rendering ancestor can no longer revive it), for both reported surfaces (Tooltip and DropdownMenu, both resolving to the fixed versions in the lockfile).
  • Regression risk: LOW. Every radix primitive Orca uses was checked before→after; all changes are bug-fixes or additive props/attributes, no removed/renamed props (types pass), and stable data-radix-* selectors Orca depends on are preserved. One visible behavior change (Select close animation, above); one dormant, non-reachable residual (cmdk, above). Full renderer suite (13,703 tests) + web typecheck green.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updated @types/react, radix-ui, react, and react-dom dependency versions in package.json.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has useful technical detail, but it does not follow the required template sections for Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes. Reformat the PR body to the repository template and add the missing sections, including screenshots/no visual change, explicit test checklist, AI review, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is specific and matches the dependency bump and React 19 crash fix described in the PR.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

#185 ref loop

radix-ui 1.4.3 bundles pre-fix sub-packages (react-slot 1.2.3, react-popper
1.2.8, react-compose-refs 1.1.2, react-menu/dropdown-menu 2.1.16) that build a
new composed callback-ref identity every render. Under React 19's re-run-on-
identity-change ref semantics, that detaches/re-attaches the ref each commit;
several primitives compose a useState setter as that ref (Tooltip
onTriggerChange, Popper onAnchorChange), so the state oscillates null<->node
and after >50 nested updates React throws #185 (Maximum update depth exceeded).
Crash e95669d2 (Tooltip->Button) and the dev DropdownMenu->Button reports.

1.6.2 bundles the fixed sub-packages (react-slot 1.3.0 memoized compose-refs,
react-popper 1.3.3, react-compose-refs 1.1.3, react-menu/dropdown-menu 2.1.20,
react-tooltip 1.2.12). Upstream radix-ui/primitives #3799 + #3963.

Also batches React-runtime patch bumps (in-range 19.2.x, low risk):
react/react-dom 19.2.5->19.2.7, @types/react 19.2.14->19.2.17.

Evidence: Orca's real Tooltip+Button tree fires the button ref 2 attaches + 1
detach on a static mount with 1.4.3 (churn), and 1 attach + 0 detach with 1.6.2
(stable). Renderer suite (13703 tests) + web typecheck green on the combined bump.

Co-authored-by: Orca <[email protected]>
@nwparker
nwparker force-pushed the nwparker/fix-radix-ref-loop branch from 78d0fa2 to 2aee9f0 Compare July 14, 2026 06:21
@nwparker nwparker changed the title fix(deps): bump radix-ui 1.4.3→1.6.2 to stop React 19 #185 ref loop (crash e95669d2) fix(deps): bump radix-ui 1.4.3→1.6.2 + react 19.2.7 to stop React 19 #185 ref loop (crash e95669d2) Jul 14, 2026
@nwparker
nwparker merged commit f01bfd9 into main Jul 14, 2026
3 checks passed
@nwparker
nwparker deleted the nwparker/fix-radix-ref-loop branch July 14, 2026 06:34
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