Skip to content

perf(router-core): skip impossible JSON parses during search parsing - #8013

Open
Sheraff wants to merge 1 commit into
mainfrom
perf/router-core-search-parse-fast-path
Open

perf(router-core): skip impossible JSON parses during search parsing#8013
Sheraff wants to merge 1 commit into
mainfrom
perf/router-core-search-parse-fast-path

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • apply the existing jsonStart fast path to parseSearchWith when using JSON.parse
  • preserve custom parser behavior and cover both paths with unit tests
  • add default search parsing benchmark scenarios and a patch changeset

Testing

  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache -- tests/searchParams.test.ts
  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:types --outputStyle=stream --skipRemoteCache
  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:eslint --outputStyle=stream --skipRemoteCache
  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache -- bench tests/searchParams.bench.ts --run

Summary by CodeRabbit

  • Bug Fixes

    • Improved search-parameter parsing by skipping values that cannot be valid JSON.
    • Preserved existing parsing behavior and silent error handling for eligible values.
  • Performance

    • Reduced unnecessary JSON parsing during search-parameter processing.
  • Tests

    • Added coverage for custom parsing, decoded parameters, invalid JSON values, and parsing performance.

@nx-cloud

nx-cloud Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit bfb5233

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 11m 58s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2m 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-08 18:40:15 UTC

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

2 package(s) bumped directly, 21 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/router-core 1.171.19 → 1.171.20 Changeset
@tanstack/start-client-core 1.170.19 → 1.170.20 Changeset
@tanstack/react-router 1.170.23 → 1.170.24 Dependent
@tanstack/react-start 1.168.40 → 1.168.41 Dependent
@tanstack/react-start-client 1.168.21 → 1.168.22 Dependent
@tanstack/react-start-rsc 0.1.39 → 0.1.40 Dependent
@tanstack/react-start-server 1.167.28 → 1.167.29 Dependent
@tanstack/router-cli 1.167.25 → 1.167.26 Dependent
@tanstack/router-generator 1.167.25 → 1.167.26 Dependent
@tanstack/router-plugin 1.168.27 → 1.168.28 Dependent
@tanstack/router-vite-plugin 1.167.27 → 1.167.28 Dependent
@tanstack/solid-router 1.170.22 → 1.170.23 Dependent
@tanstack/solid-start 1.168.39 → 1.168.40 Dependent
@tanstack/solid-start-client 1.168.21 → 1.168.22 Dependent
@tanstack/solid-start-server 1.167.28 → 1.167.29 Dependent
@tanstack/start-plugin-core 1.171.31 → 1.171.32 Dependent
@tanstack/start-server-core 1.169.23 → 1.169.24 Dependent
@tanstack/start-static-server-functions 1.167.24 → 1.167.25 Dependent
@tanstack/start-storage-context 1.167.21 → 1.167.22 Dependent
@tanstack/vue-router 1.170.21 → 1.170.22 Dependent
@tanstack/vue-start 1.168.38 → 1.168.39 Dependent
@tanstack/vue-start-client 1.167.24 → 1.167.25 Dependent
@tanstack/vue-start-server 1.167.28 → 1.167.29 Dependent

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 25e0496d-f38b-4880-b2e3-8de1cae4b5bf

📥 Commits

Reviewing files that changed from the base of the PR and between 44a8c3e and bfb5233.

📒 Files selected for processing (4)
  • .changeset/fast-search-parsing.md
  • packages/router-core/src/searchParams.ts
  • packages/router-core/tests/searchParams.bench.ts
  • packages/router-core/tests/searchParams.test.ts

📝 Walkthrough

Walkthrough

parseSearchWith now skips native JSON.parse attempts for values that cannot begin valid JSON. Tests cover custom parsers and skipped calls. Benchmarks measure parsing across several search-parameter value sets. A patch Changeset documents the behavior.

Changes

Search parameter parsing

Layer / File(s) Summary
Parser optimization and validation
packages/router-core/src/searchParams.ts, packages/router-core/tests/searchParams.test.ts, .changeset/fast-search-parsing.md
parseSearchWith detects native JSON.parse and skips values that cannot begin valid JSON. Tests cover custom parser output, decoded values, and skipped JSON.parse calls.
Parsing benchmark coverage
packages/router-core/tests/searchParams.bench.ts
Benchmarks parse ordinary, JSON-initial, JSON-compatible, and mixed serialized search values. Round-trip assertions validate the prepared fixtures.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • TanStack/router#8006: Both changes update parseSearchWith to skip impossible JSON.parse attempts and add related tests and Changesets.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main performance change in search parsing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/router-core-search-parse-fast-path

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.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 6f3a5ba67da0
  • Measured at: 2026-08-08T18:29:25.678Z
  • Baseline source: history:44a8c3e1d2af
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 83.93 KiB +18 B (+0.02%) 83.80 KiB 262.72 KiB 73.03 KiB ███████▁▁▁▁▁
react-router.full 87.45 KiB +18 B (+0.02%) 87.31 KiB 274.43 KiB 76.16 KiB ███████▁▁▁▁▁
solid-router.minimal 33.26 KiB +20 B (+0.06%) 33.13 KiB 96.55 KiB 30.05 KiB ███████▁▁▁▁▁
solid-router.full 38.08 KiB +17 B (+0.04%) 37.96 KiB 111.19 KiB 34.30 KiB ███████▁▁▁▁▁
vue-router.minimal 49.54 KiB +20 B (+0.04%) 49.42 KiB 138.30 KiB 44.75 KiB ███████▁▁▁▁▁
vue-router.full 55.12 KiB +16 B (+0.03%) 55.00 KiB 156.47 KiB 49.64 KiB ███████▁▁▁▁▁
react-start.minimal 96.77 KiB +16 B (+0.02%) 96.64 KiB 304.93 KiB 83.86 KiB ███████▁▁▁▁▁
react-start.deferred-hydration 97.50 KiB +16 B (+0.02%) 96.66 KiB 306.29 KiB 84.51 KiB ███████▁▁▁▁▁
react-start.full 99.94 KiB +20 B (+0.02%) 99.80 KiB 314.65 KiB 86.61 KiB ███████▁▁▁▁▁
react-start.rsbuild.minimal 100.08 KiB +18 B (+0.02%) 99.91 KiB 315.48 KiB 86.35 KiB ▁▄▄▃▃▄▄▄▄▆▇█
react-start.rsbuild.minimal-iife 100.49 KiB +19 B (+0.02%) 100.32 KiB 316.42 KiB 86.61 KiB ▁▄▄▃▃▄▄▄▄▆▇█
react-start.rsbuild.full 103.41 KiB +17 B (+0.02%) 103.24 KiB 325.57 KiB 89.02 KiB ▁▃▃▃▃▄▄▄▄▆▇█
solid-start.minimal 46.03 KiB +16 B (+0.03%) 45.90 KiB 137.61 KiB 40.94 KiB ███████▁▁▁▁▁
solid-start.deferred-hydration 49.10 KiB +15 B (+0.03%) 45.96 KiB 145.07 KiB 43.73 KiB ███████▁▁▁▁▁
solid-start.full 51.11 KiB +17 B (+0.03%) 50.98 KiB 153.00 KiB 45.31 KiB ███████▁▁▁▁▁
vue-start.minimal 65.56 KiB +14 B (+0.02%) 65.44 KiB 189.12 KiB 58.36 KiB ███████▁▁▁▁▁
vue-start.full 69.39 KiB +19 B (+0.03%) 69.26 KiB 201.40 KiB 61.67 KiB ███████▁▁▁▁▁

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@pkg-pr-new

pkg-pr-new Bot commented Aug 8, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: bfb5233

@codspeed-hq

codspeed-hq Bot commented Aug 8, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 10.71%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
❌ 5 regressed benchmarks
✅ 172 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server error-paths unmatched (react) 272.3 KB 849.3 KB -67.93%
Memory mem client unique-location-churn (solid) 352.4 KB 457.4 KB -22.96%
Memory mem client navigation-churn (solid) 575 KB 629 KB -8.58%
Memory mem client unique-location-churn (vue) 1.2 MB 1.3 MB -6.16%
Memory mem server server-fn-churn (vue) 263.2 KB 274.8 KB -4.21%
Memory mem server error-paths not-found (solid) 728.6 KB 417 KB +74.72%
Memory mem client preload-churn (vue) 805.5 KB 736.6 KB +9.35%
Memory mem server error-paths not-found (react) 260.8 KB 250.3 KB +4.18%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf/router-core-search-parse-fast-path (bfb5233) with main (44a8c3e)

Open in CodSpeed

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