-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid unnecessary console error on fetcher abort due to back-to-back revalidation calls #12050
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@remix-run/router": patch | ||
--- | ||
|
||
Avoid unnecessary `console.error` on fetcher abort due to back-to-back revalidation calls |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1979,9 +1979,7 @@ export function createRouter(init: RouterInit): Router { | |
} | ||
|
||
revalidatingFetchers.forEach((rf) => { | ||
if (fetchControllers.has(rf.key)) { | ||
abortFetcher(rf.key); | ||
} | ||
abortFetcher(rf.key); | ||
if (rf.controller) { | ||
// Fetchers use an independent AbortController so that aborting a fetcher | ||
// (via deleteFetcher) does not abort the triggering navigation that | ||
|
@@ -2022,6 +2020,7 @@ export function createRouter(init: RouterInit): Router { | |
abortPendingFetchRevalidations | ||
); | ||
} | ||
|
||
revalidatingFetchers.forEach((rf) => fetchControllers.delete(rf.key)); | ||
|
||
// If any loaders returned a redirect Response, start a new REPLACE navigation | ||
|
@@ -2049,7 +2048,6 @@ export function createRouter(init: RouterInit): Router { | |
let { loaderData, errors } = processLoaderData( | ||
state, | ||
matches, | ||
matchesToLoad, | ||
loaderResults, | ||
pendingActionResult, | ||
revalidatingFetchers, | ||
|
@@ -2139,7 +2137,8 @@ export function createRouter(init: RouterInit): Router { | |
); | ||
} | ||
|
||
if (fetchControllers.has(key)) abortFetcher(key); | ||
abortFetcher(key); | ||
|
||
let flushSync = (opts && opts.flushSync) === true; | ||
|
||
let routesToUse = inFlightDataRoutes || dataRoutes; | ||
|
@@ -2412,9 +2411,7 @@ export function createRouter(init: RouterInit): Router { | |
existingFetcher ? existingFetcher.data : undefined | ||
); | ||
state.fetchers.set(staleKey, revalidatingFetcher); | ||
if (fetchControllers.has(staleKey)) { | ||
abortFetcher(staleKey); | ||
} | ||
abortFetcher(staleKey); | ||
if (rf.controller) { | ||
fetchControllers.set(staleKey, rf.controller); | ||
} | ||
|
@@ -2480,7 +2477,6 @@ export function createRouter(init: RouterInit): Router { | |
let { loaderData, errors } = processLoaderData( | ||
state, | ||
matches, | ||
matchesToLoad, | ||
loaderResults, | ||
undefined, | ||
revalidatingFetchers, | ||
|
@@ -2934,8 +2930,8 @@ export function createRouter(init: RouterInit): Router { | |
fetchLoadMatches.forEach((_, key) => { | ||
if (fetchControllers.has(key)) { | ||
cancelledFetcherLoads.add(key); | ||
abortFetcher(key); | ||
} | ||
abortFetcher(key); | ||
}); | ||
} | ||
|
||
|
@@ -3018,9 +3014,10 @@ export function createRouter(init: RouterInit): Router { | |
|
||
function abortFetcher(key: string) { | ||
let controller = fetchControllers.get(key); | ||
invariant(controller, `Expected fetch controller: ${key}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All but 2 uses of |
||
controller.abort(); | ||
fetchControllers.delete(key); | ||
if (controller) { | ||
controller.abort(); | ||
fetchControllers.delete(key); | ||
} | ||
} | ||
|
||
function markFetchersDone(keys: string[]) { | ||
|
@@ -5354,7 +5351,6 @@ function processRouteLoaderData( | |
function processLoaderData( | ||
state: RouterState, | ||
matches: AgnosticDataRouteMatch[], | ||
matchesToLoad: AgnosticDataRouteMatch[], | ||
results: Record<string, DataResult>, | ||
pendingActionResult: PendingActionResult | undefined, | ||
revalidatingFetchers: RevalidatingFetcher[], | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was unused