@tanstack/router-core 1.123.0 → 1.123.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/router.cjs +15 -9
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +15 -9
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +26 -16
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -1791,16 +1791,9 @@ export class RouterCore<
|
|
|
1791
1791
|
location: this.latestLocation,
|
|
1792
1792
|
pendingMatches,
|
|
1793
1793
|
// If a cached moved to pendingMatches, remove it from cachedMatches
|
|
1794
|
-
cachedMatches: s.cachedMatches.filter(
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
if (!pendingMatch) return true
|
|
1798
|
-
|
|
1799
|
-
return (
|
|
1800
|
-
cachedMatch.status === 'success' &&
|
|
1801
|
-
(cachedMatch.isFetching || cachedMatch.loaderData !== undefined)
|
|
1802
|
-
)
|
|
1803
|
-
}),
|
|
1794
|
+
cachedMatches: s.cachedMatches.filter(
|
|
1795
|
+
(d) => !pendingMatches.find((e) => e.id === d.id),
|
|
1796
|
+
),
|
|
1804
1797
|
}))
|
|
1805
1798
|
}
|
|
1806
1799
|
|
|
@@ -2208,7 +2201,15 @@ export class RouterCore<
|
|
|
2208
2201
|
|
|
2209
2202
|
// Wait for the beforeLoad to resolve before we continue
|
|
2210
2203
|
await existingMatch.beforeLoadPromise
|
|
2211
|
-
|
|
2204
|
+
const match = this.getMatch(matchId)!
|
|
2205
|
+
if (match.status === 'error') {
|
|
2206
|
+
executeBeforeLoad = true
|
|
2207
|
+
} else if (
|
|
2208
|
+
match.preload &&
|
|
2209
|
+
(match.status === 'redirected' || match.status === 'notFound')
|
|
2210
|
+
) {
|
|
2211
|
+
handleRedirectAndNotFound(match, match.error)
|
|
2212
|
+
}
|
|
2212
2213
|
}
|
|
2213
2214
|
if (executeBeforeLoad) {
|
|
2214
2215
|
// If we are not in the middle of a load OR the previous load failed, start it
|
|
@@ -2337,14 +2338,23 @@ export class RouterCore<
|
|
|
2337
2338
|
validResolvedMatches.forEach(({ id: matchId, routeId }, index) => {
|
|
2338
2339
|
matchPromises.push(
|
|
2339
2340
|
(async () => {
|
|
2340
|
-
const { loaderPromise: prevLoaderPromise } =
|
|
2341
|
-
this.getMatch(matchId)!
|
|
2342
|
-
|
|
2343
2341
|
let loaderShouldRunAsync = false
|
|
2344
2342
|
let loaderIsRunningAsync = false
|
|
2345
2343
|
|
|
2346
|
-
|
|
2347
|
-
|
|
2344
|
+
const prevMatch = this.getMatch(matchId)!
|
|
2345
|
+
// there is a loaderPromise, so we are in the middle of a load
|
|
2346
|
+
if (prevMatch.loaderPromise) {
|
|
2347
|
+
// do not block if we already have stale data we can show
|
|
2348
|
+
// but only if the ongoing load is not a preload since error handling is different for preloads
|
|
2349
|
+
// and we don't want to swallow errors
|
|
2350
|
+
if (
|
|
2351
|
+
prevMatch.status === 'success' &&
|
|
2352
|
+
!sync &&
|
|
2353
|
+
!prevMatch.preload
|
|
2354
|
+
) {
|
|
2355
|
+
return this.getMatch(matchId)!
|
|
2356
|
+
}
|
|
2357
|
+
await prevMatch.loaderPromise
|
|
2348
2358
|
const match = this.getMatch(matchId)!
|
|
2349
2359
|
if (match.error) {
|
|
2350
2360
|
handleRedirectAndNotFound(match, match.error)
|