fix(react-router): skip manifest patch caching on aborted route discovery - #15359
Open
kdelay wants to merge 1 commit into
Open
fix(react-router): skip manifest patch caching on aborted route discovery#15359kdelay wants to merge 1 commit into
kdelay wants to merge 1 commit into
Conversation
…very fetchAndApplyManifestPatches mutated manifest.routes and added the paths to the discoveredPaths cache as soon as the manifest response settled, but the router's patch callback no-ops once the triggering navigation/fetcher signal has aborted. An abort landing in that window left the paths cached as discovered with the route tree never patched, so every later navigation to those paths early-returned from discovery for the rest of the session. Bail out before both mutations when the signal has aborted.
Contributor
|
Contributor
✅ Change File FoundOne or more change files found.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fetchAndApplyManifestPatchesmutatesmanifest.routesand adds the requested paths to the module-leveldiscoveredPathscache as soon as the manifest response settles, but thepatchcallback the router hands topatchRoutesOnNavigationno-ops once the triggering navigation/fetcher signal has aborted (router.ts).If an abort lands in the window between the manifest JSON settling and the patches being applied, the paths end up cached as discovered while the client route tree was never patched. Every later navigation to those paths early-returns at the
discoveredPathscheck, so discovery never runs again for the rest of the session — a splat route can match instead and its server loader runs, or a later child patch fails withNo route found to patch children into. Only a hard reload clears it, since the cache is module state.This bails out before either mutation when the signal has aborted, so an aborted discovery leaves no trace and the next navigation to that path discovers it normally. The eager prefetch path in
useFogOFWarDiscoverypasses no signal, so it is unaffected.Closes #15327
Tests
packages/react-router/__tests__/dom/ssr/fog-of-war-test.tsnow drivesgetPatchRoutesOnNavigationFunctionwith a mockedfetch(aslazy-discovery-test.tsdoes) and apatchthat mirrors the router's abort no-op: