Skip to content

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

Open
LadyBluenotes wants to merge 7 commits into
mainfrom
fix/rsc-slot-preview-graphs
Open

LadyBluenotes wants to merge 7 commits into
mainfrom
fix/rsc-slot-preview-graphs

Conversation

@LadyBluenotes

@LadyBluenotes LadyBluenotes commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

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

@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

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 7e6b7e1 and 7d9f399.

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 db00a10 and 82e3187.

📒 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
Loading
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 name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: handling shared and cyclic slot preview arguments in React Start RSC.
Description check ✅ Passed The 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 ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check 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.

@nx-cloud

nx-cloud Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 7d9f399

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:50 UTC

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

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

🟩 Patch bumps

Package Version Reason
@tanstack/react-start-rsc 0.1.65 → 0.1.66 Changeset
@tanstack/react-start 1.169.4 → 1.169.5 Dependent

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
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

@codspeed

codspeed Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 3.5%

2 warnings

⚠️ 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

⚠️ 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

Mode Benchmark BASE HEAD Efficiency
⚡ Memory mem client interrupted-navigations (react) 94.7 KB 91.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. ↩

@changeset-bot

changeset-bot Bot commented Oct 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7d9f399

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

This branch has not been deployed

No deployments
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.

1 participant