-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Which project does this relate to?
Start
Describe the bug
We are running across Uncaught TypeError: $R[index] is not a function when streaming through TanStack Query. In the loader, we call ensureQueryData but don't await it, and in the underlying <Section> component useSuspenseQuery. Each <Section> is wrapped with a suspense.
This is only occurring on very large pages, and only on production builds. It's difficult to reproduce, but it happens quite often in a real-world app, but not consistently. Perhaps it is a race condition? When this happens:
- The data comes in correctly from the server, and is present in the HTML source
- In the HTML source, the
$R[index]is defined, and it's a function - The
$R[index]is accessed as many times as there are<Section>s in the page - There seems to be some cleanup that perhaps removes the
$R[index]prematurely? - When the error is thrown, each Suspense goes into fallback indefinitely
I had an AI write a minimal reproduction off of the actual project, and the issue can be reproduced, but you might have to reload a few times, and I find that when running locally, throttling the network makes it occur a lot more often.
I have attached a screen recording below.
Your Example Website or App
https://github.com/ali-idrizi/tanstack-start-large-page-stream
Steps to Reproduce the Bug or Issue
npm run build && npm run start- In Chrome, throttle network to Fast 4G
- Monitor the console, and reload a few times until you see the error
Expected behavior
Each chunk/section should resolve correctly, and replace the fallback
Screenshots or Videos
2025-12-16.13-17-50.mp4
Platform
- Router / Start Version: 5.90.14
- OS: Windows
- Browser: Chrome
- Browser Version: 143
- Bundler: Vite
- Bundler Version: 7.3.0
Additional context
No response