react/scripts
Joseph Savona fa9bea0c41
Initial implementation of cache cleanup (#22510)
This is an initial, partial implementation of a cleanup mechanism for the experimental Cache API. The idea is that consumers of the Cache API can register to be informed when a given Cache instance is no longer needed so that they can perform associated cleanup tasks to free resources stored in the cache. A canonical example would be cancelling pending network requests.

An overview of the high-level changes:

* Changes the `Cache` type from a Map of cache instances to be an object with the original Map of instances, a reference count (to count roughly "active references" to the cache instances - more below), and an AbortController.
* Adds a new public API, `unstable_getCacheSignal(): AbortSignal`, which is callable during render. It returns an AbortSignal tied to the lifetime of the cache - developers can listen for the 'abort' event on the signal, which React now triggers when a given cache instance is no longer referenced. 
  * Note that `AbortSignal` is a web standard that is supported by other platform APIs; for example a signal can be passed to `fetch()` to trigger cancellation of an HTTP request.
* Implements the above - triggering the 'abort' event - by handling passive mount/unmount for HostRoot and CacheComponent fiber nodes.

Cases handled:
* Aborted transitions: we clean up a new cache created for an aborted transition
* Suspense: we retain a fresh cache instance until a suspended tree resolves

For follow-ups:
* When a subsequent cache refresh is issued before a previous refresh completes, the refreshes are queued. Fresh cache instances for previous refreshes in the queue should be cleared, retaining only the most recent cache. I plan to address this in a follow-up PR.
* If a refresh is cancelled, the fresh cache should be cleaned up.
2021-10-21 14:11:42 -07:00
..
babel Add comment support to `@gate` pragma (#21881) 2021-07-14 10:36:24 -07:00
bench Bump ecstatic from 2.2.1 to 2.2.2 in /scripts/bench (#20468) 2021-06-29 16:53:31 -04:00
circleci [build2 -> build] Local scripts 2021-09-21 15:14:09 -04:00
devtools React DevTools 4.19.2 -> 4.20.2 (#22569) 2021-10-15 12:50:17 -04:00
error-codes [Fizz/Flight] pipeToNodeWritable(..., writable).startWriting() -> renderToPipeableStream(...).pipe(writable) (#22450) 2021-10-06 00:31:06 -04:00
eslint Pass extra CLI args through to ESLint (#20250) 2020-11-13 11:00:45 -08:00
eslint-rules [RFC] Codemod invariant -> throw new Error (#22435) 2021-09-30 12:01:28 -07:00
flow Improve DEV errors if string coercion throws (Temporal.*, Symbol, etc.) (#22064) 2021-09-27 10:05:07 -07:00
git Remove leftover env variable logic in pre-commit hook 2015-09-01 14:35:47 -07:00
jest Initial implementation of cache cleanup (#22510) 2021-10-21 14:11:42 -07:00
merge-fork Improve DEV errors if string coercion throws (Temporal.*, Symbol, etc.) (#22064) 2021-09-27 10:05:07 -07:00
perf-counters Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
prettier DevTools: Update named hooks match to use column number also (#21833) 2021-07-08 16:12:22 -04:00
print-warnings [RFC] Codemod invariant -> throw new Error (#22435) 2021-09-30 12:01:28 -07:00
release Increase polling threshold for publish-prereleases (#22392) 2021-09-21 18:43:59 -07:00
rollup Scheduling Profiler: De-emphasize React internal frames (#22588) 2021-10-21 14:40:41 -04:00
shared [RFC] Codemod invariant -> throw new Error (#22435) 2021-09-30 12:01:28 -07:00
tasks Parallelize Flow in CI (#20794) 2021-02-10 17:54:58 -06:00
yarn chore: upgrade to jest 24 (#15778) 2019-10-03 22:44:18 +05:30
authors AUTHORS 2013-09-09 23:42:54 -07:00