fix(react-start-rsc): handle shared and cyclic slot preview arguments #8274
main fromfix/rsc-slot-preview-graphs·opened 🎯 Changes#
Development RSC slot previews recursively cloned every occurrence of a shared object and overflowed the stack on cyclic arguments. Memoize sanitized objects and arrays per slot call so shared references reuse one clone and cycles terminate, while retaining React-element placeholders and leaving the input untouched.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I fully understand the code in this pull request, including any code generated with AI assistance.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
- Bug Fixes
- Improved development previews to correctly preserve shared object references and circular references when passing slot data from server to client.
- Prevented excessive recursion and potential stack overflow when processing cyclic or deeply connected data.
- Preserved supported values, including sparse arrays, dates, callbacks,
null, andundefined, without modifying the original data. - Ensured React elements are safely represented during preview processing without changing the original data.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-start-rsc
View your CI Pipeline Execution ↗ for commit 7d9f3999b3d1531dbab2c966646674e1fbe92668
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...❌ Failed 14m 29s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-24 19:10:50UTCBundle Size Benchmarks#
This pull request does not affect bundle size in any measured scenario.
More templates
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsbuild
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-example-next-migration
- tanstack-start-example-rscs
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
@tanstack/arktype-adapter
npm i https://pkg.pr.new/@tanstack/arktype-adapter@8274@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8274@tanstack/eslint-plugin-start
npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8274@tanstack/history
npm i https://pkg.pr.new/@tanstack/history@8274@tanstack/react-router
npm i https://pkg.pr.new/@tanstack/react-router@8274@tanstack/react-router-devtools
npm i https://pkg.pr.new/@tanstack/react-router-devtools@8274@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8274@tanstack/react-start
npm i https://pkg.pr.new/@tanstack/react-start@8274@tanstack/react-start-client
npm i https://pkg.pr.new/@tanstack/react-start-client@8274@tanstack/react-start-rsc
npm i https://pkg.pr.new/@tanstack/react-start-rsc@8274@tanstack/react-start-server
npm i https://pkg.pr.new/@tanstack/react-start-server@8274@tanstack/router-cli
npm i https://pkg.pr.new/@tanstack/router-cli@8274@tanstack/router-core
npm i https://pkg.pr.new/@tanstack/router-core@8274@tanstack/router-devtools
npm i https://pkg.pr.new/@tanstack/router-devtools@8274@tanstack/router-devtools-core
npm i https://pkg.pr.new/@tanstack/router-devtools-core@8274@tanstack/router-generator
npm i https://pkg.pr.new/@tanstack/router-generator@8274@tanstack/router-plugin
npm i https://pkg.pr.new/@tanstack/router-plugin@8274@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8274@tanstack/router-utils
npm i https://pkg.pr.new/@tanstack/router-utils@8274@tanstack/router-vite-plugin
npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8274@tanstack/solid-router
npm i https://pkg.pr.new/@tanstack/solid-router@8274@tanstack/solid-router-devtools
npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8274@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8274@tanstack/solid-start
npm i https://pkg.pr.new/@tanstack/solid-start@8274@tanstack/solid-start-client
npm i https://pkg.pr.new/@tanstack/solid-start-client@8274@tanstack/solid-start-server
npm i https://pkg.pr.new/@tanstack/solid-start-server@8274@tanstack/start-client-core
npm i https://pkg.pr.new/@tanstack/start-client-core@8274@tanstack/start-fn-stubs
npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8274@tanstack/start-plugin-core
npm i https://pkg.pr.new/@tanstack/start-plugin-core@8274@tanstack/start-server-core
npm i https://pkg.pr.new/@tanstack/start-server-core@8274@tanstack/start-static-server-functions
npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8274@tanstack/start-storage-context
npm i https://pkg.pr.new/@tanstack/start-storage-context@8274@tanstack/valibot-adapter
npm i https://pkg.pr.new/@tanstack/valibot-adapter@8274@tanstack/virtual-file-routes
npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8274@tanstack/vue-router
npm i https://pkg.pr.new/@tanstack/vue-router@8274@tanstack/vue-router-devtools
npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8274@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8274@tanstack/vue-start
npm i https://pkg.pr.new/@tanstack/vue-start@8274@tanstack/vue-start-client
npm i https://pkg.pr.new/@tanstack/vue-start-client@8274@tanstack/vue-start-server
npm i https://pkg.pr.new/@tanstack/vue-start-server@8274@tanstack/zod-adapter
npm i https://pkg.pr.new/@tanstack/zod-adapter@8274commit:
7d9f399Merging this PR will improve performance by 3.5%#
2 warnings
:warning: 38 benchmarks are dominated by system calls
System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
:warning: Base and head ran on different runner types
Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.
⚡ 1improved benchmark✅ 193untouched benchmarks⏩ 3skipped benchmarks1Performance Changes#
Mode Benchmark BASEHEADEfficiency ⚡ Memory mem client interrupted-navigations (react)94.7 KB 91.5 KB +3.5% Tip
Curious why performance improved? Comment
@codspeedbot explain why performance improvedon this PR, or directly use the CodSpeed MCP with your agent.
Comparingfix/rsc-slot-preview-graphs(7d9f399) withmain(6b9fe6d)Footnotes#
-
3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
🦋 Changeset detected#
Latest commit: 7d9f3999b3d1531dbab2c966646674e1fbe92668
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 2 packages
Name Type @tanstack/react-start-rsc Patch @tanstack/react-start Patch Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Sign in to join this conversation.
Important
Review skipped#
Review was skipped as selected files did not have any reviewable changes.
96ff368a-4d8e-4db8-b53e-ac1713d040adReviewing files that changed from the base of the PR and between 7e6b7e110fc95e0a2557fe4ad9a24c924700d07c and 7d9f3999b3d1531dbab2c966646674e1fbe92668.
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review.
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Team
Run ID:
16380585-96f7-4066-9234-5faf00d24416📥 Commits
Reviewing files that changed from the base of the PR and between db00a10dd5a12bbdf3259721f317bd0cf1eb02e0 and 82e3187cebe6d4bb72c41c51bc7b5998f5a2dcf0.
📒 Files selected for processing (1)
packages/react-start-rsc/tests/slotUsageSanitizer.test.tsxIncluded review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Walkthrough
The slot argument sanitizer now preserves shared object references and cyclic object or array references. Unit tests, an RSC route, and an end-to-end test verify the behavior. A patch changeset documents the release.
Changes: Slot argument reference preservation
packages/react-start-rsc/src/slotUsageSanitizer.ts,packages/react-start-rsc/tests/slotUsageSanitizer.test.tsx,.changeset/calm-crabs-turn.mdsanitizeSlotArguses aWeakMapto reuse cloned containers and prevent unbounded recursion. Tests cover shared values, cycles, sparse arrays, non-plain values, input immutability, and per-call isolation.e2e/react-start/rsc/src/routes/rsc-slot-jsx-args.tsx,e2e/react-start/rsc/tests/rsc-slot-jsx-args.spec.tsCampaignMetawith shared nested references and a self-reference. The client renders the preservation result, and the test verifies the output text.Estimated code review effort: 3 (Moderate) | ~20 minutes
Sequence Diagram(s)#
Merge Risk:
Minimal · up to
e0352Slot previews now preserve shared and cyclic argument references without mutating inputs, with coverage for sanitizer behavior and server-to-client rendering. No current merge-blocking risk is identified.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
🧪 Generate unit tests (beta)
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