@@ -1968,9 +1968,7 @@ export function createRouter(init: RouterInit): Router {
19681968 }
19691969
19701970 revalidatingFetchers . forEach ( ( rf ) => {
1971- if ( fetchControllers . has ( rf . key ) ) {
1972- abortFetcher ( rf . key ) ;
1973- }
1971+ abortFetcher ( rf . key ) ;
19741972 if ( rf . controller ) {
19751973 // Fetchers use an independent AbortController so that aborting a fetcher
19761974 // (via deleteFetcher) does not abort the triggering navigation that
@@ -2011,6 +2009,7 @@ export function createRouter(init: RouterInit): Router {
20112009 abortPendingFetchRevalidations
20122010 ) ;
20132011 }
2012+
20142013 revalidatingFetchers . forEach ( ( rf ) => fetchControllers . delete ( rf . key ) ) ;
20152014
20162015 // If any loaders returned a redirect Response, start a new REPLACE navigation
@@ -2038,7 +2037,6 @@ export function createRouter(init: RouterInit): Router {
20382037 let { loaderData, errors } = processLoaderData (
20392038 state ,
20402039 matches ,
2041- matchesToLoad ,
20422040 loaderResults ,
20432041 pendingActionResult ,
20442042 revalidatingFetchers ,
@@ -2107,7 +2105,8 @@ export function createRouter(init: RouterInit): Router {
21072105 href : string | null ,
21082106 opts ?: RouterFetchOptions
21092107 ) {
2110- if ( fetchControllers . has ( key ) ) abortFetcher ( key ) ;
2108+ abortFetcher ( key ) ;
2109+
21112110 let flushSync = ( opts && opts . flushSync ) === true ;
21122111
21132112 let routesToUse = inFlightDataRoutes || dataRoutes ;
@@ -2370,9 +2369,7 @@ export function createRouter(init: RouterInit): Router {
23702369 existingFetcher ? existingFetcher . data : undefined
23712370 ) ;
23722371 state . fetchers . set ( staleKey , revalidatingFetcher ) ;
2373- if ( fetchControllers . has ( staleKey ) ) {
2374- abortFetcher ( staleKey ) ;
2375- }
2372+ abortFetcher ( staleKey ) ;
23762373 if ( rf . controller ) {
23772374 fetchControllers . set ( staleKey , rf . controller ) ;
23782375 }
@@ -2438,7 +2435,6 @@ export function createRouter(init: RouterInit): Router {
24382435 let { loaderData, errors } = processLoaderData (
24392436 state ,
24402437 matches ,
2441- matchesToLoad ,
24422438 loaderResults ,
24432439 undefined ,
24442440 revalidatingFetchers ,
@@ -2863,8 +2859,8 @@ export function createRouter(init: RouterInit): Router {
28632859 fetchLoadMatches . forEach ( ( _ , key ) => {
28642860 if ( fetchControllers . has ( key ) ) {
28652861 cancelledFetcherLoads . add ( key ) ;
2866- abortFetcher ( key ) ;
28672862 }
2863+ abortFetcher ( key ) ;
28682864 } ) ;
28692865 }
28702866
@@ -2941,9 +2937,10 @@ export function createRouter(init: RouterInit): Router {
29412937
29422938 function abortFetcher ( key : string ) {
29432939 let controller = fetchControllers . get ( key ) ;
2944- invariant ( controller , `Expected fetch controller: ${ key } ` ) ;
2945- controller . abort ( ) ;
2946- fetchControllers . delete ( key ) ;
2940+ if ( controller ) {
2941+ controller . abort ( ) ;
2942+ fetchControllers . delete ( key ) ;
2943+ }
29472944 }
29482945
29492946 function markFetchersDone ( keys : string [ ] ) {
@@ -5154,7 +5151,6 @@ function processRouteLoaderData(
51545151function processLoaderData (
51555152 state : RouterState ,
51565153 matches : AgnosticDataRouteMatch [ ] ,
5157- matchesToLoad : AgnosticDataRouteMatch [ ] ,
51585154 results : Record < string , DataResult > ,
51595155 pendingActionResult : PendingActionResult | undefined ,
51605156 revalidatingFetchers : RevalidatingFetcher [ ] ,
0 commit comments