Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/good-months-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-router": patch
---

Switch Lazy Route Discovery manifest URL generation to usea standalone `URLSearchParams` instance instead of `URL.searchParams` to avoid a major performance bottleneck in Chrome
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
- remorses
- renyu-io
- reyronald
- richardscarrott
- rifaidev
- rimian
- robbtraister
Expand Down
10 changes: 8 additions & 2 deletions packages/react-router/lib/dom/ssr/fog-of-war.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,18 @@ export async function fetchAndApplyManifestPatches(
patchRoutes: DataRouter["patchRoutes"],
signal?: AbortSignal,
): Promise<void> {
// NOTE: Intentionally using a standalone `URLSearchParams` instance
// instead of mutating `url.searchParams`, which is *significantly* slower:
// https://issues.chromium.org/issues/331406951
// https://github.com/nodejs/node/issues/51518
const searchParams = new URLSearchParams();
paths.sort().forEach((path) => searchParams.append("p", path));
searchParams.set("version", manifest.version);
let url = new URL(
getManifestPath(manifestPath, basename),
window.location.origin,
);
paths.sort().forEach((path) => url.searchParams.append("p", path));
url.searchParams.set("version", manifest.version);
url.search = searchParams.toString();

// If the URL is nearing the ~8k limit on GET requests, skip this optimization
// step and just let discovery happen on link click. We also wipe out the
Expand Down