Repository navigation
fix: reset preload flags when a route preload throws - #716
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 10452bd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
If a route
preloadthrows, every later query read in the session is treated as a preload. Query redirects and thrownResponses are then ignored. A redirect thrown by a guard query reaches the nearestErroredboundary as a rawResponseinstead of navigating. One hover over a link whose route preload has a bug is enough to cause this.Root cause
preloadRoutesets the module-levelpreloadIntentto"preload"andinPreloadFntotrue, runs each matched level'spreload, then resets both after the loop. The reset is not in afinally, so a throw fromroute.preload()orcomponent.preload()skips it.queryreadspreloadIntenton every call and skipssettle()andhandleResponsewhile it is set.createRouteContexthas the same pattern forinPreloadFn.Changes
preloadRouterestores both flags in afinally.createRouteContextrestoresinPreloadFnin afinally. The root-level preload inrouters/components.tsxalready did this.false, so a preload started from inside another preload does not clear the outer one's flag.Verification
test/preload-throw.spec.tsxcovers a throw fromusePreloadRoutefollowed by a redirecting query, a nested preload, and a throw from a route preload during navigation. Both tests fail onnextand pass with this change.npx vitest run: 730 passednpx vitest run --config vitest.config.server.ts: 105 passednpm run test:typesandnpm run build: pass🤖 Generated with Claude Code