-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Initial implementation of cache cleanup #22510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ) { | ||
| if (!rootDoesHavePassiveEffects) { | ||
| rootDoesHavePassiveEffects = true; | ||
| pendingPassiveEffectsRemainingLanes = remainingLanes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to store this to know which lanes were remaining when flushPassiveEffects() runs asynchronously
|
Okay @acdlite this is ready for another review pass! |
packages/react-reconciler/src/__tests__/StrictEffectsModeDefaults-test.internal.js
Outdated
Show resolved
Hide resolved
|
Comparing: bfb4022...dcf04a4 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
db7944f to
4ba534c
Compare
acdlite
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉🎉🎉 Yay! Thanks so much for pushing this feature through! I think the rest we can address in follow up PRs.
Looks like you'll need to pull upstream changes and resolve them one more time before merging.
Very exciting!
f2a9fc7 to
6fae379
Compare
Summary
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:
Cachetype 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.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.AbortSignalis a web standard that is supported by other platform APIs; for example a signal can be passed tofetch()to trigger cancellation of an HTTP request.Cases handled:
For follow-ups:
How did you test this change?
yarn test --all- a few tests are still failing and i'll need some guidance on how to resolve those (i'll post more details later).