@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.
@@ -503,11 +503,9 @@ class RouterCore {
503
503
  location: this.latestLocation,
504
504
  pendingMatches,
505
505
  // If a cached moved to pendingMatches, remove it from cachedMatches
506
- cachedMatches: s.cachedMatches.filter((cachedMatch) => {
507
- const pendingMatch = pendingMatches.find((e) => e.id === cachedMatch.id);
508
- if (!pendingMatch) return true;
509
- return cachedMatch.status === "success" && (cachedMatch.isFetching || cachedMatch.loaderData !== void 0);
510
- })
506
+ cachedMatches: s.cachedMatches.filter(
507
+ (d) => !pendingMatches.find((e) => e.id === d.id)
508
+ )
511
509
  }));
512
510
  };
513
511
  this.load = async (opts) => {
@@ -798,7 +796,12 @@ class RouterCore {
798
796
  }, pendingMs);
799
797
  }
800
798
  await existingMatch.beforeLoadPromise;
801
- executeBeforeLoad = this.getMatch(matchId).status === "error";
799
+ const match = this.getMatch(matchId);
800
+ if (match.status === "error") {
801
+ executeBeforeLoad = true;
802
+ } else if (match.preload && (match.status === "redirected" || match.status === "notFound")) {
803
+ handleRedirectAndNotFound(match, match.error);
804
+ }
802
805
  }
803
806
  if (executeBeforeLoad) {
804
807
  try {
@@ -890,11 +893,14 @@ class RouterCore {
890
893
  validResolvedMatches.forEach(({ id: matchId, routeId }, index) => {
891
894
  matchPromises.push(
892
895
  (async () => {
893
- const { loaderPromise: prevLoaderPromise } = this.getMatch(matchId);
894
896
  let loaderShouldRunAsync = false;
895
897
  let loaderIsRunningAsync = false;
896
- if (prevLoaderPromise) {
897
- await prevLoaderPromise;
898
+ const prevMatch = this.getMatch(matchId);
899
+ if (prevMatch.loaderPromise) {
900
+ if (prevMatch.status === "success" && !sync && !prevMatch.preload) {
901
+ return this.getMatch(matchId);
902
+ }
903
+ await prevMatch.loaderPromise;
898
904
  const match = this.getMatch(matchId);
899
905
  if (match.error) {
900
906
  handleRedirectAndNotFound(match, match.error);