fix: ensure context is consistent on concurrent match loads#1891
Closed
freshgiammi wants to merge 3 commits intoTanStack:mainfrom
freshgiammi:beforeload_context_preload
Closed
fix: ensure context is consistent on concurrent match loads#1891freshgiammi wants to merge 3 commits intoTanStack:mainfrom freshgiammi:beforeload_context_preload
freshgiammi wants to merge 3 commits intoTanStack:mainfrom
freshgiammi:beforeload_context_preload
Conversation
Contributor
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 11e02da. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targetsSent with 💌 from NxCloud. |
freshgiammi
commented
Jul 5, 2024
| checkLatest() | ||
|
|
||
| // Kick off the loader! | ||
| loaderPromise = route.options.loader?.(loaderContext) |
Contributor
Author
There was a problem hiding this comment.
Weirdly enough, doing
matches[index] = match = updateMatch(
match.id,
(prev) => ({
...prev,
loaderPromise: route.options.loader?.(loaderContext),
}),
)
instead of this breaks navigate from working 🤔
schiller-manuel
added a commit
that referenced
this pull request
Jul 6, 2024
this currently fails!
AssertionError: expected "spy" to be called 2 times, but got 1 times
❯ tests/routeContext.test.tsx:417:18
415|
416| // Expect double call: once from preload, once from navigate
417| expect(mock).toHaveBeenCalledTimes(2)
| ^
418| })
419|
Contributor
|
closing in favor of #1907 |
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 match has multiple load routines running (such as navigation happening while preload isn't finished yet), we might start the
loaderfunction too early when the context isn't ready for consumption yet.This happens because execution flow is skipped when a route already in beforeLoad fetching state is re-loaded.
This patch adds beforeLoad tracking to matched routes, so that we can eventually await any pending beforeLoad function and ensure we have up to date context to feed into the
loaderfunction.Fixes #1886