Skip to content

fix: handle URL changes before hydration starts - #2317

Open
brenelz wants to merge 1 commit into
solidjs:mainfrom
brenelz:fix/early-navigation-hydration
Open

fix: handle URL changes before hydration starts#2317
brenelz wants to merge 1 commit into
solidjs:mainfrom
brenelz:fix/early-navigation-hydration

Conversation

@brenelz

@brenelz brenelz commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #2313.

If the browser URL changes before the client router initializes, hydration currently tries to match the new route against the previous route’s server-rendered HTML. This can throw a hydration mismatch and leave the app blank. A query-only change can also silently reuse stale server data.

  • Record the server-rendered pathname and query on the existing client entry script with data-start-url.
  • Compare that URL with the current browser location in mount().
  • If the path or query changed, mark hydration as done and disable queued hydration events before calling Solid’s existing client-render fallback. Late SSR fragments are discarded, and the requested route renders with fresh client data.
  • Preserve normal hydration for hash-only changes.
  • Include a patch changeset.

The guard handles the early URL change in the issue’s reproduction. A real link navigation while the initial route module is still loading is also covered by a control test. This works with the current Solid dependencies.

Regression coverage

The tests pin the timing by holding the client entry request, rather than sweeping machine-dependent delays:

  • Pathname change before hydration.
  • Pathname change while the original response is streaming.
  • Query-only change while streaming, checking that the new query gets fresh data.
  • Hash-only change, checking that the original DOM is hydrated rather than replaced.
  • Real link navigation while the initial route module is pending.

They assert interactive content, a single layout and page, and no browser errors. The path and query cases failed before the fix; the hash-only control passed.

Verification

  • Focused Playwright suite plus the existing hydration smoke test: 6 passed in standard dev and 6 passed in bundled dev.
  • Production build: the four early-URL-change cases plus the hydration smoke test: 5 passed.
  • pnpm --filter @solidjs/start test:ci: 114 tests passed.
  • pnpm --filter @solidjs/start typecheck
  • pnpm --filter @solidjs/start validate-imports
  • pnpm --filter @solidjs/start build
  • pnpm --filter tests build
  • Formatting and git diff --check passed.

@changeset-bot

changeset-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c3c46b0

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

This PR includes changesets to release 1 package
Name Type
@solidjs/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

@netlify

netlify Bot commented Sep 11, 2026

Copy link
Copy Markdown

Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit c3c46b0
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6aa362dc23b046000810b656
😎 Deploy Preview https://deploy-preview-2317--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2317

commit: c3c46b0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Client-side navigation during hydration causes hydration issue.

1 participant