File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
packages/react-router/lib/dom/ssr Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " react-router " : patch
3
+ ---
4
+
5
+ Switch Lazy Route Discovery manifest URL generation to usea standalone ` URLSearchParams ` instance instead of ` URL.searchParams ` to avoid a major performance bottleneck in Chrome
Original file line number Diff line number Diff line change 310
310
- remorses
311
311
- renyu-io
312
312
- reyronald
313
+ - richardscarrott
313
314
- rifaidev
314
315
- rimian
315
316
- robbtraister
Original file line number Diff line number Diff line change @@ -217,12 +217,18 @@ export async function fetchAndApplyManifestPatches(
217
217
patchRoutes : DataRouter [ "patchRoutes" ] ,
218
218
signal ?: AbortSignal ,
219
219
) : Promise < void > {
220
+ // NOTE: Intentionally using a standalone `URLSearchParams` instance
221
+ // instead of mutating `url.searchParams`, which is *significantly* slower:
222
+ // https://issues.chromium.org/issues/331406951
223
+ // https://github.com/nodejs/node/issues/51518
224
+ const searchParams = new URLSearchParams ( ) ;
225
+ paths . sort ( ) . forEach ( ( path ) => searchParams . append ( "p" , path ) ) ;
226
+ searchParams . set ( "version" , manifest . version ) ;
220
227
let url = new URL (
221
228
getManifestPath ( manifestPath , basename ) ,
222
229
window . location . origin ,
223
230
) ;
224
- paths . sort ( ) . forEach ( ( path ) => url . searchParams . append ( "p" , path ) ) ;
225
- url . searchParams . set ( "version" , manifest . version ) ;
231
+ url . search = searchParams . toString ( ) ;
226
232
227
233
// If the URL is nearing the ~8k limit on GET requests, skip this optimization
228
234
// step and just let discovery happen on link click. We also wipe out the
You can’t perform that action at this time.
0 commit comments