Page freezes when a Suspense boundary suspends again while retrying hydration #137
Hi! I had a try using Redact and intlayer webapps and the homepage froze on load.
Chrome showed the "Page unresponsive" dialog. With plain React 19 the same build works fine. Changing the feature flags didn't help (redact(), or redact({ features: { ... } })).
After some digging in an unminified build, the console was full of the bare Error() that flushPending throws after 50 passes. It fires over and over, and the microtask loop never gives the main thread back.
What seems to happen:
- The landing page sits in a server-rendered
<Suspense>. Its content suspends during the first hydration (our dictionaries load lazily), so the boundary getswset andretryHydrationwaits on the promise. All good so far. - When it retries (
renderSuspense, thestate.w && state.b && state.ebranch), the markup no longer matches the server, sohydrateSuspenseBoundaryfalls back torecoverBoundaryHydration. That client-renders withroot.h = false. - A child suspends during that client render.
suspendHandlerisn't set on this path, sorealHandleSuspendedthrows aRenderSuspenseCapture, and the capture doesn't carry the promise. - The
catchin that branch only callsretryHydrationfor thenables, so the capture is rethrown.renderUpdatesthen reschedules the boundary right away, the child suspends on the same pending promise, and it goes round again.
Versions:
-@tanstack/redact 0.2.5,
- Vite 8.3.5,
@tanstack/react-start1.169.
Awesome project btw, and nice approach,
It works well for 2/4 apps tested, the two remaining failed for the same reason due to Suspense
Thanks for digging into this and sharing the fix. The hydration retry path you described is being checked now.
AI review notes: The supplied commit changes only the Suspense hydration-retry handler, one regression test and a changeset. The agent has inspected the full patch and is preparing isolated baseline and candidate controls. The commit and contributor attribution will be preserved. This is not yet a verified fix or a shipped change, the issue will remain open through validation and delivery.
Happy to test it when released I will take case closing the issue if resolved
Thanks, that would help. The reduced case now reproduces the freeze, and your fix passes the regression checks.
AI review notes: The unchanged runtime hits the 50-iteration guard when hydration suspends a second time. The candidate passes 2,058 tests, types and build checks, plus native React and Redact controls in Chromium, Firefox and WebKit. One fixed size limit needs a three-byte gzip increase. That exact allowance has been requested, the fix has not merged or shipped yet. The original commit credit is retained. The issue will stay open for your app verification after release.
Sign in to join this conversation.
I can't pull request, but here is a commit fixing it https://github.com/aymericzip/redact/commit/0b0e5f6e4428b5d79956cf84be1e8c99f8139ea1