File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
packages/react-router/lib/dom/ssr Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,25 @@ export async function fetchAndApplyManifestPatches(
242242 try {
243243 let res = await fetch ( url , { signal } ) ;
244244
245+ // To avoid issues during rolling deployments if we get back a 400 when
246+ // using `paths`, it's likely we hit an old server so retry the request
247+ // with the old `p` parameters
248+ if ( res . status === 400 ) {
249+ let body = await res . text ( ) ;
250+ if ( body !== "Invalid Request" ) {
251+ throw new Error ( `${ res . status } ${ res . statusText } ` ) ;
252+ }
253+ const retrySearchParams = new URLSearchParams ( ) ;
254+ paths . sort ( ) . forEach ( ( path ) => retrySearchParams . append ( "p" , path ) ) ;
255+ retrySearchParams . set ( "version" , manifest . version ) ;
256+ let url = new URL (
257+ getManifestPath ( manifestPath , basename ) ,
258+ window . location . origin ,
259+ ) ;
260+ url . search = retrySearchParams . toString ( ) ;
261+ res = await fetch ( url , { signal } ) ;
262+ }
263+
245264 if ( ! res . ok ) {
246265 throw new Error ( `${ res . status } ${ res . statusText } ` ) ;
247266 } else if (
You can’t perform that action at this time.
0 commit comments