Skip to content

fix(vite): merge @radix-ui into react chunk to break load-order cycle (prod hotfix)#3204

Merged
drewstone merged 1 commit into
developfrom
fix/vite-react-radix-chunk-cycle
May 14, 2026
Merged

fix(vite): merge @radix-ui into react chunk to break load-order cycle (prod hotfix)#3204
drewstone merged 1 commit into
developfrom
fix/vite-react-radix-chunk-cycle

Conversation

@drewstone
Copy link
Copy Markdown
Contributor

Production incident

`cloud.tangle.tools` is hard-broken right now:

```
TypeError: Cannot read properties of undefined (reading 'forwardRef')
at Yu (radix-TkqFv_GX.js:1:7237)
at Gu (radix-TkqFv_GX.js:1:6817)
at Array.reduce ()
```

Only the purple background shell mounts; `#root` stays empty.

Root cause

The post-#3199/#3203 rebuild produced a circular chunk graph:

```
react-.js ──imports _getDefaultExportFromCjs from──▶ radix-.js
radix-.js ──top-level Qu.reduce → Yu → i.forwardRef──▶ react-.js
```

Rollup hoists the CJS-interop helper into whichever chunk happens to own the right modules under the current content-hash layout. On this build it landed in radix, so react imported it back. radix's top-level `Primitive.*` reduce (which calls `forwardRef` for every primitive tag) ran before react's named exports were initialised → crash at module init.

This bug has been latent since #3185 (vendor chunk split). Content-hash-driven Rollup chunk shuffling exposed it on the ABI-sync rebuild. `tangle-dapp` has the same config and was one lucky chunk layout away from the same outage.

Fix

Co-locate `react` / `react-dom` with `@radix-ui` in a single chunk. `@radix-ui` already depends on react, so they must evaluate in this order anyway — putting them together makes the chunk graph acyclic.

Applied to both `apps/tangle-cloud/vite.config.ts` and `apps/tangle-dapp/vite.config.ts`.

Verification

  • `yarn build:tangle-cloud` → react chunk has zero cross-chunk imports (leaf), no other chunk forms a cycle with it
  • `yarn build:tangle-dapp` → react chunk imports only from `noble` (also a leaf), acyclic
  • Both built dists mount cleanly under `python3 -m http.server` with zero `pageerror` events in Playwright

Rollout

This needs the standard develop → staging → master cascade ASAP since prod is down.

cloud.tangle.tools was hard-broken (`TypeError: Cannot read properties
of undefined (reading 'forwardRef')`, only the purple background shell
visible) because the post-#3199/#3203 rebuild produced this chunk graph:

  react-*.js  ──imports `_getDefaultExportFromCjs` from──▶  radix-*.js
  radix-*.js  ──top-level Qu.reduce → Yu → `i.forwardRef`──▶  react-*.js

Rollup hoists the CJS-interop helper into whichever chunk happens to
own the right modules under the current content-hash layout. On this
build it landed in radix, so react imported it back, forming a cycle
that crashed at module init: radix's top-level Primitive.* reduce ran
before react's named exports were initialised.

Fix: co-locate react/react-dom with @radix-ui in a single chunk.
@radix-ui already depends on react, so they must evaluate in this
order anyway — putting them together makes the chunk graph acyclic.

Verified locally on both apps:
- tangle-cloud: react chunk has zero cross-chunk imports → leaf
- tangle-dapp: react chunk imports only from `noble` (also a leaf)
- Both apps mount cleanly under preview with no pageerror events
@drewstone drewstone requested a review from AtelyPham as a code owner May 14, 2026 10:06
@netlify
Copy link
Copy Markdown

netlify Bot commented May 14, 2026

Deploy Preview for tangle-dapp ready!

Name Link
🔨 Latest commit 3d6b5fd
🔍 Latest deploy log https://app.netlify.com/projects/tangle-dapp/deploys/6a059e9e32e709000814bbe8
😎 Deploy Preview https://deploy-preview-3204--tangle-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 14, 2026

Deploy Preview for tangle-cloud ready!

Name Link
🔨 Latest commit 3d6b5fd
🔍 Latest deploy log https://app.netlify.com/projects/tangle-cloud/deploys/6a059e9e659641000763a42b
😎 Deploy Preview https://deploy-preview-3204--tangle-cloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 14, 2026

Deploy Preview for tangle-leaderboard ready!

Name Link
🔨 Latest commit 3d6b5fd
🔍 Latest deploy log https://app.netlify.com/projects/tangle-leaderboard/deploys/6a059e9e80fca50008ed0a81
😎 Deploy Preview https://deploy-preview-3204--tangle-leaderboard.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@drewstone drewstone merged commit 9c0e4c4 into develop May 14, 2026
20 checks passed
@drewstone drewstone deleted the fix/vite-react-radix-chunk-cycle branch May 14, 2026 10:11
drewstone added a commit that referenced this pull request May 14, 2026
… to master

Promotes:
- #3204 fix(vite): merge @radix-ui into react chunk to break load-order cycle
- #3206 feat(tangle-cloud): wire dispute-bond claim flow (v0.15.0)
- #3208 chore: retire `staging` branch, document develop → master flow

This is the first non-cascade release after retiring the staging branch.
From this point forward, every `[RELEASE]`-tagged commit on develop
auto-promotes to master via auto-sync-master-with-develop.yml.
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