Skip to content

fix(router-core): align calculation of publicHref in parseLocation and buildLocation#7069

Merged
nlynzaad merged 8 commits intomainfrom
align-parseLocation-buildLocation
Mar 29, 2026
Merged

fix(router-core): align calculation of publicHref in parseLocation and buildLocation#7069
nlynzaad merged 8 commits intomainfrom
align-parseLocation-buildLocation

Conversation

@nlynzaad
Copy link
Copy Markdown
Contributor

@nlynzaad nlynzaad commented Mar 29, 2026

fixes: #7029

This PR addresses a mismatch between parseLocation and buildLocation in determining the publicHref.

In cases where these do not match due to how buildLocation determines the path (might include encoded characters) and parseLocation that uses the processed href this can cause the loader to run a second time on client after SSR.

Summary by CodeRabbit

  • New Features

    • Added a load location indicator displaying whether page content was client or server-rendered in the special characters search page.
  • Tests

    • Enhanced test suite to verify network idle state and validate the new load location display.
  • Chores

    • Increased workspace build parallelism configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

Caution

Review failed

The head commit changed during the review from 8525d3b to 5f71fa7.

📝 Walkthrough

Walkthrough

This PR fixes a hydration bug where loaders re-ran during client-side initialization when search parameters contained special characters that encode differently on server versus client. The fix adjusts how publicHref is constructed in the router's location-parsing fast-path, verified by enhanced test coverage that asserts loaders execute in the correct environment.

Changes

Cohort / File(s) Summary
Router URL Encoding Fix
packages/router-core/src/router.ts
Changed publicHref construction in the fast-path of parseLocation from using the history-provided href to using internally constructed pathname + searchStr + hash, ensuring consistent URL encoding between server and client.
Route Handler & Loader Tracking
e2e/react-start/basic/src/routes/specialChars/search.tsx
Added browser detection constant, route loader that tracks execution location (client vs server) and logs this information, and UI element with test ID to display whether the component loaded on client or server.
E2E Test Enhancement
e2e/react-start/basic-test-suite/src/special-characters.spec.ts
Enhanced special-characters test to wait for networkidle after reaching the expected URL and verify the loader executed location via the special-search-loaded-info DOM element assertion.
Build Configuration
nx.json
Updated Nx workspace parallelism configuration from 5 to 10.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 A hop through the code with special care,
URL encoding now matched with flair,
Loaders stay put where they ought to be,
No hydration mismatch for all to see,
Paths and searches in perfect repair!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive The nx.json parallel value change from 5 to 10 appears unrelated to fixing the publicHref mismatch bug described in issue #7029 and may be out of scope. Clarify whether the nx.json parallelism change is required for this fix or if it should be in a separate PR for workspace configuration updates.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: aligning publicHref calculation between parseLocation and buildLocation to fix URL encoding mismatches that cause loader re-runs.
Linked Issues check ✅ Passed All changes directly address issue #7029 by fixing the publicHref calculation mismatch in parseLocation to align with buildLocation, preventing unnecessary loader re-runs during hydration with URL-encoded search parameters.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 align-parseLocation-buildLocation

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Mar 29, 2026

View your CI Pipeline Execution ↗ for commit 5f71fa7

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 9m 12s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 47s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-29 17:35:42 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 29, 2026

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 29, 2026

Bundle Size Benchmarks

  • Commit: 7b9faaeee045
  • Measured at: 2026-03-29T17:27:16.558Z
  • Baseline source: history:7b9faaeee045
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.47 KiB +3 B (+0.00%) 275.68 KiB 75.93 KiB ██▄▄▂▂▂▂▁▁▁▁
react-router.full 90.76 KiB +3 B (+0.00%) 286.86 KiB 78.87 KiB ██▃▃▂▂▂▂▁▁▁▁
solid-router.minimal 35.51 KiB 0 B (0.00%) 107.04 KiB 31.87 KiB ████▃▃▃▃▁▁▁
solid-router.full 39.99 KiB +1 B (+0.00%) 120.58 KiB 35.89 KiB ████▆▆▆▆▁▁▁▁
vue-router.minimal 53.36 KiB +2 B (+0.00%) 152.97 KiB 47.88 KiB ██▂▂▂▂▂▂▁▁▁▁
vue-router.full 58.22 KiB +2 B (+0.00%) 168.43 KiB 52.08 KiB ██▃▃▂▂▂▂▁▁▁▁
react-start.minimal 102.00 KiB +3 B (+0.00%) 323.92 KiB 88.17 KiB ██▃▃▂▂▂▂▁▁▁▁
react-start.full 105.36 KiB +3 B (+0.00%) 334.27 KiB 91.01 KiB ██▃▃▂▂▂▂▁▁▁▁
solid-start.minimal 49.61 KiB +3 B (+0.01%) 153.29 KiB 43.75 KiB ████▄▄▄▄▁▁▁▁
solid-start.full 55.10 KiB 0 B (0.00%) 169.53 KiB 48.46 KiB ████▅▅▅▅▁▁▁

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 29, 2026

More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: 5f71fa7

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@nx.json`:
- Line 6: This PR contains an unrelated workspace-wide CI parallelism change:
the "parallel" key in nx.json was bumped to 10; revert that change (restore the
previous value for "parallel") or remove the modified "parallel" entry from this
branch and submit it as a separate infra/CI PR with benchmarking/CI-capacity
evidence; ensure the only changes remaining in this PR touch router-core
hydration/publicHref fixes and that no other global CI settings (the "parallel"
field in nx.json) are altered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9c988c1c-a030-46f1-9156-dc7600f7b4dc

📥 Commits

Reviewing files that changed from the base of the PR and between 7b9faae and 676afa5.

📒 Files selected for processing (4)
  • e2e/react-start/basic-test-suite/src/special-characters.spec.ts
  • e2e/react-start/basic/src/routes/specialChars/search.tsx
  • nx.json
  • packages/router-core/src/router.ts

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 29, 2026

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing align-parseLocation-buildLocation (5f71fa7) with main (7b9faae)

Open in CodSpeed

@nlynzaad nlynzaad merged commit 30835cb into main Mar 29, 2026
17 checks passed
@nlynzaad nlynzaad deleted the align-parseLocation-buildLocation branch March 29, 2026 22:57
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.

Hydrated match loaderData overwritten during initial client load

1 participant