Skip to content

Bugfix: Incorrect search params stored in cache#94144

Merged
timneutkens merged 1 commit into
canaryfrom
acdlite/fix-route-cache-search-params
May 27, 2026
Merged

Bugfix: Incorrect search params stored in cache#94144
timneutkens merged 1 commit into
canaryfrom
acdlite/fix-route-cache-search-params

Conversation

@acdlite
Copy link
Copy Markdown
Contributor

@acdlite acdlite commented May 27, 2026

The route cache write was keying entries on renderedSearch — the search string the server actually used to render the page — but lookups use the requested URL's search component. These two are not equivalent: for any search-invariant route (e.g. a static page), renderedSearch is '' regardless of what the request URL carried.

The result was that a request for /a?foo=bar against a static page parked the cache entry at vary path (/a, '', null) — the same slot a clean /a lookup keys to. The entry's stored canonicalUrl came from the requesting URL (/a?foo=bar), so a later router.push('/a') or router.replace('/a') would hit that slot and restore the stale search string into the browser address bar, window.location, and useSearchParams().

The fix keys cache writes on the request URL's search, not renderedSearch. Entries now sit at the slot keyed by the request that wrote them, so a lookup for a different search variant doesn't find them.

Regression test covers the reproduction from the user repo linked in the bug reports.

Closes #91658
Closes #92187

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Stats cancelled

Commit: 84ba3e8
View workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Tests Passed

Commit: 84ba3e8

@acdlite acdlite requested a review from samselikoff May 27, 2026 02:59
@acdlite acdlite marked this pull request as ready for review May 27, 2026 03:00
The route cache write was keying entries on `renderedSearch` — the
search string the server actually used to render the page — but
lookups use the requested URL's search component. These two are not
equivalent: for any search-invariant route (e.g. a static page),
`renderedSearch` is `''` regardless of what the request URL carried.

The result was that a request for `/a?foo=bar` against a static page
parked the cache entry at vary path `(/a, '', null)` — the same slot a
clean `/a` lookup keys to. The entry's stored `canonicalUrl` came from
the requesting URL (`/a?foo=bar`), so a later `router.push('/a')` or
`router.replace('/a')` would hit that slot and restore the stale
search string into the browser address bar, `window.location`, and
`useSearchParams()`.

The fix keys cache writes on the request URL's search, not
`renderedSearch`. Entries now sit at the slot keyed by the request
that wrote them, so a lookup for a different search variant doesn't
find them.

Regression test covers the reproduction from the user repo linked in
the bug reports.

Closes #91658
Closes #92187
@acdlite acdlite force-pushed the acdlite/fix-route-cache-search-params branch from 7cea932 to 84ba3e8 Compare May 27, 2026 03:01
@timneutkens timneutkens merged commit a7877d7 into canary May 27, 2026
164 of 165 checks passed
@timneutkens timneutkens deleted the acdlite/fix-route-cache-search-params branch May 27, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants