Skip to content
Source
Sign inSign up
TanStack/router

fix(react-start-rsc): handle shared and cyclic slot preview arguments #8274

OpenLadyBluenotes(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromfix/rsc-slot-preview-graphsopened

🎯 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, and undefined, 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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      Important

      Review skipped

      Review was skipped as selected files did not have any reviewable changes.

      Run configuration
      Commits

      Reviewing 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_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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.tsx

      Included 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

      Layer / File(s)Summary
      Sanitizer reference caching
      packages/react-start-rsc/src/slotUsageSanitizer.ts, packages/react-start-rsc/tests/slotUsageSanitizer.test.tsx, .changeset/calm-crabs-turn.md
      sanitizeSlotArg uses a WeakMap to reuse cloned containers and prevent unbounded recursion. Tests cover shared values, cycles, sparse arrays, non-plain values, input immutability, and per-call isolation.
      End-to-end slot reference coverage
      e2e/react-start/rsc/src/routes/rsc-slot-jsx-args.tsx, e2e/react-start/rsc/tests/rsc-slot-jsx-args.spec.ts
      The RSC route passes CampaignMeta with 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)

      sequenceDiagram
        participant RSCServerRoute
        participant sanitizeSlotArgs
        participant RSCClientSlot
        RSCServerRoute->>sanitizeSlotArgs: pass CampaignMeta with shared references and a self-cycle
        sanitizeSlotArgs->>sanitizeSlotArgs: cache cloned containers before recursion
        sanitizeSlotArgs-->>RSCClientSlot: return metadata with preserved references and cycle
        RSCClientSlot-->>RSCClientSlot: render reference-preservation result
      Merge Risk: Minimal · up to e0352

      Slot 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)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the main change: handling shared and cyclic slot preview arguments in React Start RSC.
      Description check✅ PassedThe description explains the change, motivation, release impact, and changeset. It omits the required checklist item confirming local testing or explaining why tests do not apply, but the description …
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches: 💡 1
      📝 Generate docstrings: 💡
      • Create stacked PR
      • Commit on current branch
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `fix/rsc-slot-preview-graphs`
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      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.
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 7d9f3999b3d1531dbab2c966646674e1fbe92668

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...❌ Failed14m 29sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-24 19:10:50 UTC

    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Changeset Version Preview

      1 package(s) bumped directly, 1 bumped as dependents.

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/react-start-rsc0.1.65 → 0.1.66Changeset
      @tanstack/react-start1.169.4 → 1.169.5Dependent
    5. github-actions[bot](GitHub profile, opens in a new tab)commented

      Bundle Size Benchmarks

      This pull request does not affect bundle size in any measured scenario.

    6. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented
      More templates

      @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@8274

      commit: 7d9f399

    7. codspeed[bot](GitHub profile, opens in a new tab)commented

      Merging 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.

      Learn more about system calls

      See affected benchmarks

      :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.

      Learn more about Macro Runners

      Open the report in CodSpeed to investigate

      ⚡ 1 improved benchmark ✅ 193 untouched benchmarks ⏩ 3 skipped benchmarks1

      Performance Changes

      ModeBenchmarkBASEHEADEfficiency
      ⚡Memorymem client interrupted-navigations (react)94.7 KB91.5 KB+3.5%

      Tip

      Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


      Comparing fix/rsc-slot-preview-graphs (7d9f399) with main (6b9fe6d) Open in CodSpeed

      Footnotes

      1. 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. ↩

    8. 🦋 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
      NameType
      @tanstack/react-start-rscPatch
      @tanstack/react-startPatch

      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.