@remix-run/router 1.21.0 → 1.21.1

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.21.0
2
+ * @remix-run/router v1.21.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2043,6 +2043,14 @@
2043
2043
  });
2044
2044
  }
2045
2045
 
2046
+ // Remove any lingering deleted fetchers that have already been removed
2047
+ // from state.fetchers
2048
+ deletedFetchers.forEach(key => {
2049
+ if (!state.fetchers.has(key) && !fetchControllers.has(key)) {
2050
+ deletedFetchersKeys.push(key);
2051
+ }
2052
+ });
2053
+
2046
2054
  // Iterate over a local copy so that if flushSync is used and we end up
2047
2055
  // removing and adding a new subscriber due to the useCallback dependencies,
2048
2056
  // we don't get ourselves into a loop calling the new subscriber immediately
@@ -2056,6 +2064,10 @@
2056
2064
  if (future.v7_fetcherPersist) {
2057
2065
  completedFetchers.forEach(key => state.fetchers.delete(key));
2058
2066
  deletedFetchersKeys.forEach(key => deleteFetcher(key));
2067
+ } else {
2068
+ // We already called deleteFetcher() on these, can remove them from this
2069
+ // Set now that we've handed the keys off to the data layer
2070
+ deletedFetchersKeys.forEach(key => deletedFetchers.delete(key));
2059
2071
  }
2060
2072
  }
2061
2073
 
@@ -3314,13 +3326,11 @@
3314
3326
  });
3315
3327
  }
3316
3328
  function getFetcher(key) {
3317
- if (future.v7_fetcherPersist) {
3318
- activeFetchers.set(key, (activeFetchers.get(key) || 0) + 1);
3319
- // If this fetcher was previously marked for deletion, unmark it since we
3320
- // have a new instance
3321
- if (deletedFetchers.has(key)) {
3322
- deletedFetchers.delete(key);
3323
- }
3329
+ activeFetchers.set(key, (activeFetchers.get(key) || 0) + 1);
3330
+ // If this fetcher was previously marked for deletion, unmark it since we
3331
+ // have a new instance
3332
+ if (deletedFetchers.has(key)) {
3333
+ deletedFetchers.delete(key);
3324
3334
  }
3325
3335
  return state.fetchers.get(key) || IDLE_FETCHER;
3326
3336
  }
@@ -3335,21 +3345,29 @@
3335
3345
  fetchLoadMatches.delete(key);
3336
3346
  fetchReloadIds.delete(key);
3337
3347
  fetchRedirectIds.delete(key);
3338
- deletedFetchers.delete(key);
3348
+
3349
+ // If we opted into the flag we can clear this now since we're calling
3350
+ // deleteFetcher() at the end of updateState() and we've already handed the
3351
+ // deleted fetcher keys off to the data layer.
3352
+ // If not, we're eagerly calling deleteFetcher() and we need to keep this
3353
+ // Set populated until the next updateState call, and we'll clear
3354
+ // `deletedFetchers` then
3355
+ if (future.v7_fetcherPersist) {
3356
+ deletedFetchers.delete(key);
3357
+ }
3339
3358
  cancelledFetcherLoads.delete(key);
3340
3359
  state.fetchers.delete(key);
3341
3360
  }
3342
3361
  function deleteFetcherAndUpdateState(key) {
3343
- if (future.v7_fetcherPersist) {
3344
- let count = (activeFetchers.get(key) || 0) - 1;
3345
- if (count <= 0) {
3346
- activeFetchers.delete(key);
3347
- deletedFetchers.add(key);
3348
- } else {
3349
- activeFetchers.set(key, count);
3362
+ let count = (activeFetchers.get(key) || 0) - 1;
3363
+ if (count <= 0) {
3364
+ activeFetchers.delete(key);
3365
+ deletedFetchers.add(key);
3366
+ if (!future.v7_fetcherPersist) {
3367
+ deleteFetcher(key);
3350
3368
  }
3351
3369
  } else {
3352
- deleteFetcher(key);
3370
+ activeFetchers.set(key, count);
3353
3371
  }
3354
3372
  updateState({
3355
3373
  fetchers: new Map(state.fetchers)