Skip to content

Commit acd4efa

Browse files
committed
Add back-compat for manifest parameter
1 parent 6a92c78 commit acd4efa

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

.changeset/rare-jobs-remember.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
[REMOVE] Follow up to https://github.com/remix-run/react-router/pull/14321 to avoid issues with rolling deployments

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ Date: 2025-09-24
368368

369369
### Patch Changes
370370

371-
- `react-router` - Ensure client-side router runs client `middleware` on initial load even if no loaders exist ([#14348](https://github.com/remix-run/react-router/pull/14348))
371+
- `react-router` - Ensure client-side router runs client `middleware` during initialization data load (if required) even if no loaders exist ([#14348](https://github.com/remix-run/react-router/pull/14348))
372372
- `react-router` - Fix `middleware` prop not being supported on `<Route>` when used with a data router via `createRoutesFromElements` ([#14357](https://github.com/remix-run/react-router/pull/14357))
373373
- `react-router` - Update `createRoutesStub` to work with `middleware` ([#14348](https://github.com/remix-run/react-router/pull/14348))
374374
- You will need to set the `<RoutesStub future={{ v8_middleware: true }} />` flag to enable the proper `context` type

packages/react-router/lib/dom/lib.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,11 @@ export function ScrollRestoration({
20402040
}
20412041
} catch (error: unknown) {
20422042
console.error(error);
2043-
sessionStorage.removeItem(storageKey);
2043+
try {
2044+
sessionStorage.removeItem(storageKey);
2045+
} catch (e) {
2046+
// No-op
2047+
}
20442048
}
20452049
}).toString();
20462050

packages/react-router/lib/server-runtime/server.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,19 +354,15 @@ async function handleManifestRequest(
354354

355355
let patches: Record<string, EntryRoute> = {};
356356

357-
if (url.searchParams.has("paths")) {
357+
// Support both the old (`p`) and new formats (`paths`) to avoid issues during
358+
// rolling deployments where an old client hits a new server
359+
if (url.searchParams.has("p") || url.searchParams.has("paths")) {
358360
let paths = new Set<string>();
359361

360-
// In addition to responding with the patches for the requested paths, we
361-
// need to include patches for each partial path so that we pick up any
362-
// pathless/index routes below ancestor segments. So if we
363-
// get a request for `/parent/child`, we need to look for a match on `/parent`
364-
// so that if a `parent._index` route exists we return it so it's available
365-
// for client side matching if the user routes back up to `/parent`.
366-
// This is the same thing we do on initial load in <Scripts> via
367-
// `getPartialManifest()`
368-
let pathParam = url.searchParams.get("paths") || "";
369-
let requestedPaths = pathParam.split(",").filter(Boolean);
362+
let requestedPaths = url.searchParams.has("paths")
363+
? (url.searchParams.get("paths") || "").split(",").filter(Boolean)
364+
: url.searchParams.getAll("p");
365+
370366
requestedPaths.forEach((path) => {
371367
if (!path.startsWith("/")) {
372368
path = `/${path}`;
@@ -378,6 +374,14 @@ async function handleManifestRequest(
378374
});
379375
});
380376

377+
// In addition to responding with the patches for the requested paths, we
378+
// need to include patches for each partial path so that we pick up any
379+
// pathless/index routes below ancestor segments. So if we
380+
// get a request for `/parent/child`, we need to look for a match on `/parent`
381+
// so that if a `parent._index` route exists we return it so it's available
382+
// for client side matching if the user routes back up to `/parent`.
383+
// This is the same thing we do on initial load in <Scripts> via
384+
// `getPartialManifest()`
381385
for (let path of paths) {
382386
let matches = matchServerRoutes(routes, path, build.basename);
383387
if (matches) {

0 commit comments

Comments
 (0)