Skip to content

Conversation

@andyabih
Copy link
Contributor

@andyabih andyabih commented Nov 7, 2025

fixes #5383

In reference to this: facebook/react@18212ca

Currently, when the shell hits ~12.5KB, any suspense boundary larger than 500 bytes triggers an empty fallback.

This results in pages loading without the content at first, and then having them render shortly after.

This PR simply adds a way to increase that size to whatever the user deems fit if he wishes to avoid this behavior.

Summary by CodeRabbit

  • Bug Fixes
    • Modified server-side rendering streaming behavior to ensure consistent chunk handling during content delivery.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 7, 2025

Walkthrough

The SSR rendering stream configuration in React Router is updated to hardcode progressiveChunkSize to Number.POSITIVE_INFINITY in both renderToReadableStream and renderToPipeableStream function calls, replacing the previous conditional reference to router options.

Changes

Cohort / File(s) Summary
SSR streaming configuration
packages/react-router/src/ssr/renderRouterToStream.tsx
Hardcoded progressiveChunkSize: Number.POSITIVE_INFINITY in both streaming render paths, replacing router options reference

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

  • Single file with two parallel, identical configuration changes
  • No logic modifications or control-flow alterations
  • No public API signature changes

Poem

🐰 A streaming rabbit hops with glee,
No chunks to bound infinity!
Infinity now hardcoded tight,
The SSR flows without bite. 🚀

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: hardcoding progressiveChunkSize to infinity in the renderRouterToStream function.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Nov 7, 2025

View your CI Pipeline Execution ↗ for commit ff51c47

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 3m 50s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-09 10:40:50 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 7, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5790

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5790

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5790

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5790

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5790

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5790

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5790

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5790

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5790

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5790

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5790

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5790

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5790

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5790

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5790

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5790

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5790

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5790

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5790

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5790

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5790

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5790

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5790

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5790

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5790

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5790

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5790

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5790

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5790

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5790

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5790

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5790

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5790

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5790

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5790

commit: ff51c47

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/router-core/src/router.ts (1)

469-472: The React API is confirmed and properly typed—JSDoc documentation would be a nice addition.

React 19's renderToReadableStream does support a progressiveChunkSize option (number of bytes per chunk), and your type annotation is correct. Consider adding JSDoc to document its purpose and default behavior for users:

  ssr?: {
    nonce?: string
+   /**
+    * Controls the progressive chunk size threshold for SSR streaming.
+    * Number of bytes per chunk. Increase this value to reduce empty fallbacks 
+    * during initial render.
+    */
    progressiveChunkSize?: number
  }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 818a5e7 and b70260d.

📒 Files selected for processing (2)
  • packages/react-router/src/ssr/renderRouterToStream.tsx (2 hunks)
  • packages/router-core/src/router.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with extensive type safety across the codebase

Files:

  • packages/router-core/src/router.ts
  • packages/react-router/src/ssr/renderRouterToStream.tsx
packages/router-core/**

📄 CodeRabbit inference engine (AGENTS.md)

Keep framework-agnostic core router logic in packages/router-core/

Files:

  • packages/router-core/src/router.ts
packages/{react-router,solid-router}/**

📄 CodeRabbit inference engine (AGENTS.md)

Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/

Files:

  • packages/react-router/src/ssr/renderRouterToStream.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
🔇 Additional comments (1)
packages/react-router/src/ssr/renderRouterToStream.tsx (1)

24-28: LGTM with one dependency.

The implementation correctly forwards the progressiveChunkSize option to both React rendering methods. The use of optional chaining ensures safe handling when the option is not provided. Both code paths (Web Streams and Node.js Streams) are consistently updated.

However, this depends on verification that React's streaming APIs actually support this option (flagged in router.ts review).

Also applies to: 48-51

@schiller-manuel
Copy link
Contributor

progressiveChunkSize is a react config, thus cannot be in router-core

instead of making this a router option at all, i would just set the default to infinity and then expose a new reactOpts (or ideally named better) that has progressiveChunkSizeso a custom handler could configure this if needed.

cc @brhx

@brhx
Copy link
Member

brhx commented Nov 9, 2025

agree - @andyabih please could you update your PR just to have the progressive chunk size set to Infinity for now?

@andyabih
Copy link
Contributor Author

andyabih commented Nov 9, 2025

@brhx - Done!

Happy to implement a PR with the proper options when you guys decide on the best way to tackle this. Pretty invested in this specifically due to SEO concerns, so always happy to help.

@schiller-manuel schiller-manuel changed the title Add support for progressiveChunkSize fix: set progressiveChunkSize to infinity Nov 9, 2025
@schiller-manuel schiller-manuel merged commit c825684 into TanStack:main Nov 9, 2025
7 of 8 checks passed
roduyemi pushed a commit to roduyemi/oss-router that referenced this pull request Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tanstack Start base div hidden on JS disabled

3 participants