Skip to content

$R[index] is not a function when streaming on very large pages #6106

@ali-idrizi

Description

@ali-idrizi

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

  1. npm run build && npm run start
  2. In Chrome, throttle network to Fast 4G
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions