react/scripts/jest
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
..
matchers Update test and stack frame code to support newer V8 stack formats (#22477) 2021-10-11 18:40:42 -04:00
spec-equivalence-reporter Update test and stack frame code to support newer V8 stack formats (#22477) 2021-10-11 18:40:42 -04:00
typescript Remove internal `act` builds from public modules (#21721) 2021-06-22 14:29:35 -07:00
TestFlags.js Check for store mutations before commit (#22290) 2021-09-13 08:07:46 -07:00
config.base.js Update jest to v26 (#21574) 2021-05-27 16:33:57 +01:00
config.build-devtools.js [build2 -> build] Local scripts 2021-09-21 15:14:09 -04:00
config.build.js [build2 -> build] Local scripts 2021-09-21 15:14:09 -04:00
config.source-persistent.js DevTools: Show hook names based on variable usage (#21641) 2021-07-01 14:39:18 -04:00
config.source-www.js DevTools: Show hook names based on variable usage (#21641) 2021-07-01 14:39:18 -04:00
config.source.js DevTools: Show hook names based on variable usage (#21641) 2021-07-01 14:39:18 -04:00
dont-run-jest-directly.js Add error when running jest directly (#12726) 2018-05-01 12:46:17 -07:00
jest-cli.js Add new Jest --compact-console flag for DevTools tests (#22495) 2021-10-05 11:58:54 -04:00
jest.js Add new test cli (#19184) 2020-06-25 20:39:50 -04:00
jestSequencer.js Parallelize Jest in CI (#19552) 2020-08-07 16:32:59 -04:00
noHaste.js Forbid Haste in Jest (#11647) 2017-11-23 18:02:47 +00:00
preprocessor.js Update DevTools to use getCacheForType API (#20548) 2021-01-19 09:51:32 -05:00
setupEnvironment.js Initial implementation of cache cleanup (#22510) 2021-10-21 14:11:42 -07:00
setupGlobal.js Use toMatchInlineSnapshot for dehydrated values (#20618) 2021-04-26 12:30:34 -04:00
setupHostConfigs.js Resolve the true entry point during tests (#21505) 2021-06-02 18:03:29 -07:00
setupTests.build.js Update jest to v26 (#21574) 2021-05-27 16:33:57 +01:00
setupTests.js Update test and stack frame code to support newer V8 stack formats (#22477) 2021-10-11 18:40:42 -04:00
setupTests.persistent.js Update jest to v26 (#21574) 2021-05-27 16:33:57 +01:00
setupTests.www.js Set up test infra for dynamic Scheduler flags (#22139) 2021-08-20 06:56:20 -07:00
shouldIgnoreConsoleError.js Throw when `act` is used in production (#21686) 2021-06-16 16:29:51 -04:00