Skip to content
Source
Sign inSign up
TanStack/router

perf: reduce repeated Zod validation work #8305

OpenLadyBluenotes(GitHub profile, opens in a new tab)wants to merge 12 commits intomain fromperf/zod-validation-fast-pathopened

🎯 Changes

Replaces #8301 with only the Zod validation work, based directly on main.

Compile the code-splitting grouping schema and check duplicates without flattening or copying arrays. Skip Zod parsing for Rspack modules without server-function metadata. Preserve grouping diagnostics and valid metadata parsing, including cloned output and unknown-key stripping.

Add behavior tests and Vitest benchmarks for grouping validation and metadata restoration.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • 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

  • Performance

    • Improved validation efficiency for code-splitting group configurations.
    • Reduced unnecessary processing when reading server-function metadata during builds.
  • Bug Fixes

    • Modules without server-function metadata are now handled safely during builds.
    • Code-splitting configurations continue to reject duplicate or invalid entries with clearer validation results.
  • Documentation

    • Updated Zod examples and usage guidance to reflect current import conventions.
  • Tests

    • Added coverage and performance benchmarks for validation and metadata handling.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-plugin

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core

    3. Review Change StackReview Change Stack

      Note

      Reviews paused

      It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

      • Last reviewed commit: 0a079c5d5b2d6c52f7d067c843312b6121ffdfac
      • Latest commit, not reviewed: 16d948700ff30215e009061ab6c4aec9edf4171e

      Use the following commands to manage reviews:

      • @coderabbitai resume to resume automatic reviews.
      • @coderabbitai review to trigger a single review.

      Use the checkboxes below for quick actions:

      • ▶️ Resume reviews
      • 🔍 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: Advanced

      Run ID: c8a27c51-6f88-4377-9af6-37562963f1d8

      📥 Commits

      Reviewing files that changed from the base of the PR and between 572e1ad7842f59af6099f2a569687d4a6b9ea511 and 0a079c5d5b2d6c52f7d067c843312b6121ffdfac.

      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (1)
      • docs/router/how-to/share-search-params-across-routes.md

      Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

      Walkthrough

      The router plugin compiles split-group validation and detects duplicate nodes incrementally. The Start plugin tests guarded server-function metadata parsing. The change also standardizes Zod namespace imports, updates Seroval ranges, and adds benchmark scripts.

      Changes: Plugin performance updates

      Layer / File(s)Summary
      Split groupings validation
      packages/router-plugin/src/core/config.ts, packages/router-plugin/tests/split-groupings.*, packages/router-plugin/package.json
      The schema uses compiled validation and incremental duplicate detection. Tests cover valid, invalid, and duplicate groupings. Benchmarks compare compiled and uncompiled parsing.
      Server-function metadata parsing
      packages/start-plugin-core/src/rsbuild/start-compiler-host.ts, packages/start-plugin-core/tests/rsbuild/start-compiler-metadata.*, packages/start-plugin-core/package.json
      Tests cover absent, invalid, empty, and valid metadata. Benchmarks compare guarded and unguarded parsing.
      Package and import alignment
      .changeset/sweet-lions-share.md, packages/*/package.json, benchmarks/ssr/package.json, docs/**, e2e/**, examples/**
      The changeset declares patch releases. Benchmark scripts are added. Seroval ranges are updated. Zod examples, fixtures, source files, and tests use namespace imports.

      Estimated code review effort: 3 (Moderate) | ~25 minutes

      Merge Risk: Low · up to 0a079

      The change improves validation and metadata parsing performance. One documentation page may lack a visible H1 if no generated title is provided, making this a minor follow-up rather than a functional blocker.

      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5…
      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.
      Title check✅ PassedThe title clearly summarizes the primary change: reducing repeated Zod validation work through performance optimizations.
      Description check✅ PassedThe description follows the repository template, explains the changes and motivation, completes all checklist items, and identifies the release impact with a changeset.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `perf/zod-validation-fast-path`
      • 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.
    4. View your CI Pipeline Execution ↗ for commit 16d948700ff30215e009061ab6c4aec9edf4171e

      CommandStatusDurationResult
      nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 46sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-24 22:10:27 UTC

    5. 🚀 Changeset Version Preview

      6 package(s) bumped directly, 17 bumped as dependents.

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/router-core1.171.39 → 1.171.40Changeset
      @tanstack/router-plugin1.168.48 → 1.168.49Changeset
      @tanstack/start-client-core1.170.39 → 1.170.40Changeset
      @tanstack/start-plugin-core1.171.55 → 1.171.56Changeset
      @tanstack/start-server-core1.169.45 → 1.169.46Changeset
      @tanstack/start-static-server-functions1.167.44 → 1.167.45Changeset
      @tanstack/react-router1.170.46 → 1.170.47Dependent
      @tanstack/react-start1.169.4 → 1.169.5Dependent
      @tanstack/react-start-client1.168.44 → 1.168.45Dependent
      @tanstack/react-start-rsc0.1.65 → 0.1.66Dependent
      @tanstack/react-start-server1.167.52 → 1.167.53Dependent
      @tanstack/router-cli1.167.46 → 1.167.47Dependent
      @tanstack/router-generator1.167.46 → 1.167.47Dependent
      @tanstack/router-vite-plugin1.167.48 → 1.167.49Dependent
      @tanstack/solid-router1.170.43 → 1.170.44Dependent
      @tanstack/solid-start1.169.4 → 1.169.5Dependent
      @tanstack/solid-start-client1.168.42 → 1.168.43Dependent
      @tanstack/solid-start-server1.167.50 → 1.167.51Dependent
      @tanstack/start-storage-context1.167.41 → 1.167.42Dependent
      @tanstack/vue-router1.170.42 → 1.170.43Dependent
      @tanstack/vue-start1.169.4 → 1.169.5Dependent
      @tanstack/vue-start-client1.167.45 → 1.167.46Dependent
      @tanstack/vue-start-server1.167.50 → 1.167.51Dependent
    6. More templates

      @tanstack/arktype-adapter

      npm i https://pkg.pr.new/@tanstack/arktype-adapter@8305

      @tanstack/eslint-plugin-router

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

      @tanstack/eslint-plugin-start

      npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8305

      @tanstack/history

      npm i https://pkg.pr.new/@tanstack/history@8305

      @tanstack/react-router

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

      @tanstack/react-router-devtools

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

      @tanstack/react-router-ssr-query

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

      @tanstack/react-start

      npm i https://pkg.pr.new/@tanstack/react-start@8305

      @tanstack/react-start-client

      npm i https://pkg.pr.new/@tanstack/react-start-client@8305

      @tanstack/react-start-rsc

      npm i https://pkg.pr.new/@tanstack/react-start-rsc@8305

      @tanstack/react-start-server

      npm i https://pkg.pr.new/@tanstack/react-start-server@8305

      @tanstack/router-cli

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

      @tanstack/router-core

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

      @tanstack/router-devtools

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

      @tanstack/router-devtools-core

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

      @tanstack/router-generator

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

      @tanstack/router-plugin

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

      @tanstack/router-ssr-query-core

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

      @tanstack/router-utils

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

      @tanstack/router-vite-plugin

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

      @tanstack/solid-router

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

      @tanstack/solid-router-devtools

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

      @tanstack/solid-router-ssr-query

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

      @tanstack/solid-start

      npm i https://pkg.pr.new/@tanstack/solid-start@8305

      @tanstack/solid-start-client

      npm i https://pkg.pr.new/@tanstack/solid-start-client@8305

      @tanstack/solid-start-server

      npm i https://pkg.pr.new/@tanstack/solid-start-server@8305

      @tanstack/start-client-core

      npm i https://pkg.pr.new/@tanstack/start-client-core@8305

      @tanstack/start-fn-stubs

      npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8305

      @tanstack/start-plugin-core

      npm i https://pkg.pr.new/@tanstack/start-plugin-core@8305

      @tanstack/start-server-core

      npm i https://pkg.pr.new/@tanstack/start-server-core@8305

      @tanstack/start-static-server-functions

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

      @tanstack/start-storage-context

      npm i https://pkg.pr.new/@tanstack/start-storage-context@8305

      @tanstack/valibot-adapter

      npm i https://pkg.pr.new/@tanstack/valibot-adapter@8305

      @tanstack/virtual-file-routes

      npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8305

      @tanstack/vue-router

      npm i https://pkg.pr.new/@tanstack/vue-router@8305

      @tanstack/vue-router-devtools

      npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8305

      @tanstack/vue-router-ssr-query

      npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8305

      @tanstack/vue-start

      npm i https://pkg.pr.new/@tanstack/vue-start@8305

      @tanstack/vue-start-client

      npm i https://pkg.pr.new/@tanstack/vue-start-client@8305

      @tanstack/vue-start-server

      npm i https://pkg.pr.new/@tanstack/vue-start-server@8305

      @tanstack/zod-adapter

      npm i https://pkg.pr.new/@tanstack/zod-adapter@8305

      commit: 16d9487

    7. Bundle Size Benchmarks

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

    8. Merging this PR will not alter performance

      1 warning

      :warning: 37 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

      ✅ 194 untouched benchmarks ⏩ 3 skipped benchmarks1


      Comparing perf/zod-validation-fast-path (16d9487) with main (6b9fe6d)[^unexpected-base] 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. ↩

    9. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core

    10. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core

    11. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-client-core

    12. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-static-server-functions

    13. github-actions[bot](GitHub profile, opens in a new tab) added labelsdocumentation

    14. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-router

    15. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-generator

    16. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-utils

    17. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: zod-adapter

    18. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-router

    19. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-start

    20. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: vue-router

    21. Important

      At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

      Nx Cloud is proposing a fix for your failed CI:

      We've reverted the seroval/seroval-plugins bump from ^1.6.2 to ^1.6.7 that was introduced on this branch (not present on main) but never mentioned in the PR's stated intent of reducing Zod validation work. This dependency handles promise/stream serialization for SSR, and it was the only plausible source of the tanstack-solid-start-e2e-serialization-adapters:test:e2e failure, where the "stream" test hung for 30s waiting on a suspended Await boundary to resolve. Restoring 1.6.2 removes the incidental regression risk while keeping the actual Zod code-splitting/metadata compilation changes intact.

      Tip

      ✅ We verified this fix by re-running tanstack-solid-start-e2e-serialization-adapters:test:e2e.

      Warning

      The suggested diff is too large to display here, but you can view it on Nx Cloud ↗


      Apply fix via Nx Cloud  Reject fix via Nx Cloud


      Or Apply changes locally with:

      npx nx-cloud apply-locally 5Syb-JdUf
      Apply fix locally with your editor ↗   View interactive diff ↗

      🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)
    22. 🦋 Changeset detected

      Latest commit: 16d948700ff30215e009061ab6c4aec9edf4171e

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 23 packages
      NameType
      @tanstack/router-corePatch
      @tanstack/router-pluginPatch
      @tanstack/start-client-corePatch
      @tanstack/start-plugin-corePatch
      @tanstack/start-server-corePatch
      @tanstack/start-static-server-functionsPatch
      @tanstack/react-routerPatch
      @tanstack/react-start-clientPatch
      @tanstack/react-start-rscPatch
      @tanstack/react-start-serverPatch
      @tanstack/router-generatorPatch
      @tanstack/solid-routerPatch
      @tanstack/solid-start-clientPatch
      @tanstack/solid-start-serverPatch
      @tanstack/start-storage-contextPatch
      @tanstack/vue-routerPatch
      @tanstack/vue-start-clientPatch
      @tanstack/vue-start-serverPatch
      @tanstack/router-vite-pluginPatch
      @tanstack/react-startPatch
      @tanstack/solid-startPatch
      @tanstack/vue-startPatch
      @tanstack/router-cliPatch

      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

    23. docs/router/api/router/retainSearchParamsFunction.md line 16
      @@ -13,4 +13,3 @@
      1313 ## Examples
      1414
      1515 ```tsx
      16-import { z } from 'zod'

      why were thoses imports changed?

    24. please split this into separate PRs (e.g. one for zod upgrade, ...)

Sign in to join this conversation.