GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Initial implementation of cache cleanup by josephsavona · Pull Request #22510 · react/react

Conversation

@josephsavona

@josephsavona josephsavona commented Oct 5, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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:

  • 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.

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).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

wongmjane reacted with thumbs up emoji NE-SmallTown reacted with eyes emoji
All reactions
  • 👍 1 reaction
  • 👀 1 reaction
@josephsavona josephsavona changed the title Cache cleanup 2 Initial implementation of cache cleanup Oct 5, 2021
@josephsavona
josephsavona requested a review from acdlite October 5, 2021 19:34
@josephsavona josephsavona changed the title Initial implementation of cache cleanup [wip] Initial implementation of cache cleanup Oct 5, 2021
@facebook-github-bot facebook-github-bot added the CLA Signed label Oct 5, 2021
josephsavona
josephsavona commented Oct 5, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCacheComponent.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberCacheComponent.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberCacheComponent.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

josephsavona
josephsavona commented Oct 5, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/__tests__/ReactCache-test.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/__tests__/ReactCache-test.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

acdlite
acdlite reviewed Oct 6, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCacheComponent.old.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

acdlite
acdlite reviewed Oct 6, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberLane.old.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

josephsavona
josephsavona commented Oct 7, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/__tests__/ReactCache-test.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

acdlite
acdlite reviewed Oct 8, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberWorkLoop.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

acdlite
acdlite reviewed Oct 8, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberWorkLoop.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

acdlite
acdlite reviewed Oct 8, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberWorkLoop.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberRoot.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberWorkLoop.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberHooks.old.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

josephsavona
josephsavona commented Oct 8, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberRoot.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

josephsavona
josephsavona commented Oct 8, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberWorkLoop.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

josephsavona
josephsavona commented Oct 8, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberWorkLoop.new.js
) {
if (!rootDoesHavePassiveEffects) {
rootDoesHavePassiveEffects = true;
pendingPassiveEffectsRemainingLanes = remainingLanes;

@josephsavona josephsavona Oct 8, 2021

Copy link
Copy Markdown
Contributor Author

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
josephsavona
josephsavona commented Oct 8, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberWorkLoop.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@josephsavona

josephsavona commented Oct 12, 2021

Copy link
Copy Markdown
Contributor Author

Okay @acdlite this is ready for another review pass!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

josephsavona
josephsavona commented Oct 12, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/__tests__/StrictEffectsModeDefaults-test.internal.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@josephsavona josephsavona changed the title [wip] Initial implementation of cache cleanup Initial implementation of cache cleanup Oct 12, 2021
@josephsavona josephsavona mentioned this pull request Oct 14, 2021
Duplicate of #22510 to see if CI will run #22555
Closed
acdlite
acdlite reviewed Oct 19, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/__tests__/ReactCache-test.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

acdlite
acdlite reviewed Oct 19, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/__tests__/ReactCache-test.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

acdlite
acdlite reviewed Oct 19, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCompleteWork.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

acdlite
acdlite reviewed Oct 19, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCompleteWork.old.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

josephsavona
josephsavona commented Oct 20, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCompleteWork.old.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sizebot

sizebot commented Oct 20, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: bfb4022...dcf04a4

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 130.19 kB 130.19 kB = 41.41 kB 41.41 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +1.61% 133.02 kB 135.16 kB +1.33% 42.39 kB 42.95 kB
facebook-www/ReactDOM-prod.classic.js +1.34% 414.34 kB 419.90 kB +1.01% 76.56 kB 77.33 kB
facebook-www/ReactDOM-prod.modern.js +1.38% 402.93 kB 408.48 kB +1.03% 74.82 kB 75.59 kB
facebook-www/ReactDOMForked-prod.classic.js +1.34% 414.34 kB 419.90 kB +1.01% 76.56 kB 77.34 kB
oss-experimental/react-test-renderer/umd/react-test-renderer.production.min.js +2.62% 82.32 kB 84.48 kB +2.44% 25.76 kB 26.39 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.production.min.js +2.61% 82.14 kB 84.28 kB +1.84% 25.39 kB 25.86 kB
oss-experimental/react-art/cjs/react-art.production.min.js +2.52% 85.39 kB 87.54 kB +2.16% 26.44 kB 27.01 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.min.js +2.27% 94.61 kB 96.76 kB +1.80% 28.95 kB 29.47 kB
facebook-www/ReactART-prod.modern.js +2.21% 261.79 kB 267.58 kB +1.72% 46.80 kB 47.60 kB
facebook-www/ReactART-prod.classic.js +2.15% 269.45 kB 275.24 kB +1.74% 48.04 kB 48.88 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.min.js +2.07% 103.64 kB 105.78 kB +1.87% 31.52 kB 32.11 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-test-renderer/umd/react-test-renderer.production.min.js +2.62% 82.32 kB 84.48 kB +2.44% 25.76 kB 26.39 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.production.min.js +2.61% 82.14 kB 84.28 kB +1.84% 25.39 kB 25.86 kB
oss-experimental/react-art/cjs/react-art.production.min.js +2.52% 85.39 kB 87.54 kB +2.16% 26.44 kB 27.01 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.min.js +2.27% 94.61 kB 96.76 kB +1.80% 28.95 kB 29.47 kB
facebook-www/ReactART-prod.modern.js +2.21% 261.79 kB 267.58 kB +1.72% 46.80 kB 47.60 kB
facebook-www/ReactART-prod.classic.js +2.15% 269.45 kB 275.24 kB +1.74% 48.04 kB 48.88 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.min.js +2.07% 103.64 kB 105.78 kB +1.87% 31.52 kB 32.11 kB
oss-experimental/react-art/umd/react-art.production.min.js +1.73% 121.31 kB 123.41 kB +1.43% 37.66 kB 38.19 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.development.js +1.71% 636.28 kB 647.18 kB +1.71% 139.50 kB 141.88 kB
oss-experimental/react-test-renderer/umd/react-test-renderer.development.js +1.70% 667.09 kB 678.46 kB +1.69% 141.08 kB 143.47 kB
facebook-www/ReactTestRenderer-dev.classic.js +1.66% 659.07 kB 669.98 kB +1.63% 141.92 kB 144.24 kB
facebook-www/ReactTestRenderer-dev.modern.js +1.66% 659.08 kB 670.00 kB +1.63% 141.93 kB 144.25 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +1.61% 133.02 kB 135.16 kB +1.33% 42.39 kB 42.95 kB
oss-experimental/react-dom/umd/react-dom.production.min.js +1.57% 133.11 kB 135.21 kB +1.24% 43.07 kB 43.61 kB
oss-experimental/react-art/cjs/react-art.development.js +1.57% 693.58 kB 704.47 kB +1.57% 150.42 kB 152.77 kB
oss-experimental/react-dom/cjs/react-dom.profiling.min.js +1.49% 143.11 kB 145.25 kB +1.12% 45.47 kB 45.98 kB
facebook-www/ReactART-dev.modern.js +1.49% 733.72 kB 744.63 kB +1.51% 156.71 kB 159.08 kB
facebook-www/ReactART-dev.classic.js +1.47% 743.91 kB 754.83 kB +1.49% 158.81 kB 161.17 kB
oss-experimental/react-dom/umd/react-dom.profiling.min.js +1.46% 142.02 kB 144.10 kB +1.12% 45.79 kB 46.30 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js +1.46% 744.92 kB 755.81 kB +1.43% 158.45 kB 160.72 kB
oss-experimental/react-art/umd/react-art.development.js +1.42% 797.42 kB 808.77 kB +1.36% 168.36 kB 170.65 kB
facebook-www/ReactDOMTesting-prod.modern.js +1.40% 396.84 kB 402.40 kB +1.00% 75.10 kB 75.85 kB
facebook-www/ReactDOM-prod.modern.js +1.38% 402.93 kB 408.48 kB +1.03% 74.82 kB 75.59 kB
facebook-www/ReactDOMForked-prod.modern.js +1.38% 402.93 kB 408.48 kB +1.03% 74.82 kB 75.59 kB
facebook-www/ReactDOMTesting-prod.classic.js +1.35% 410.13 kB 415.68 kB +0.97% 77.23 kB 77.98 kB
facebook-www/ReactDOM-prod.classic.js +1.34% 414.34 kB 419.90 kB +1.01% 76.56 kB 77.33 kB
facebook-www/ReactDOMForked-prod.classic.js +1.34% 414.34 kB 419.90 kB +1.01% 76.56 kB 77.34 kB
facebook-www/ReactDOM-profiling.modern.js +1.22% 435.41 kB 440.74 kB +0.93% 80.49 kB 81.24 kB
facebook-www/ReactDOMForked-profiling.modern.js +1.22% 435.41 kB 440.74 kB +0.93% 80.50 kB 81.25 kB
facebook-www/ReactDOM-profiling.classic.js +1.19% 446.88 kB 452.21 kB +0.97% 82.17 kB 82.96 kB
facebook-www/ReactDOMForked-profiling.classic.js +1.19% 446.88 kB 452.21 kB +0.97% 82.17 kB 82.97 kB
oss-experimental/react/cjs/react-unstable-shared-subset.production.min.js +1.19% 6.55 kB 6.63 kB +0.41% 2.68 kB 2.69 kB
facebook-www/ReactDOMTesting-dev.modern.js +1.11% 987.97 kB 998.95 kB +1.06% 222.36 kB 224.72 kB
facebook-www/ReactDOMTesting-dev.classic.js +1.08% 1,014.67 kB 1,025.64 kB +1.04% 227.78 kB 230.16 kB
oss-experimental/react-dom/cjs/react-dom.development.js +1.07% 1,018.65 kB 1,029.54 kB +1.01% 228.69 kB 231.01 kB
oss-experimental/react-dom/umd/react-dom.development.js +1.06% 1,068.67 kB 1,080.01 kB +1.00% 231.04 kB 233.35 kB
facebook-www/ReactDOMForked-dev.modern.js +1.01% 1,076.95 kB 1,087.86 kB +0.97% 238.75 kB 241.07 kB
facebook-www/ReactDOM-dev.modern.js +1.01% 1,076.95 kB 1,087.86 kB +0.97% 238.75 kB 241.07 kB
oss-experimental/react/cjs/react.production.min.js +1.00% 7.83 kB 7.90 kB +0.27% 2.98 kB 2.99 kB
facebook-www/ReactDOMForked-dev.classic.js +0.99% 1,101.02 kB 1,111.93 kB +0.95% 243.60 kB 245.92 kB
facebook-www/ReactDOM-dev.classic.js +0.99% 1,101.02 kB 1,111.93 kB +0.95% 243.60 kB 245.92 kB
facebook-react-native/react/cjs/React-prod.js +0.63% 17.21 kB 17.32 kB +0.21% 4.39 kB 4.40 kB
facebook-www/React-prod.modern.js +0.62% 17.29 kB 17.40 kB +0.27% 4.42 kB 4.43 kB
facebook-www/React-prod.classic.js +0.62% 17.44 kB 17.54 kB +0.18% 4.47 kB 4.47 kB
oss-experimental/react/umd/react.profiling.min.js +0.61% 11.82 kB 11.89 kB +0.28% 4.63 kB 4.64 kB
oss-experimental/react/umd/react.production.min.js +0.61% 11.82 kB 11.89 kB +0.28% 4.63 kB 4.64 kB
facebook-react-native/react/cjs/React-profiling.js +0.59% 18.36 kB 18.47 kB +0.33% 4.56 kB 4.58 kB
facebook-www/React-profiling.modern.js +0.59% 18.44 kB 18.54 kB +0.33% 4.59 kB 4.61 kB
facebook-www/React-profiling.classic.js +0.58% 18.58 kB 18.69 kB +0.30% 4.64 kB 4.65 kB
oss-experimental/react/cjs/react-unstable-shared-subset.development.js +0.27% 75.01 kB 75.22 kB +0.13% 20.52 kB 20.55 kB
oss-experimental/react/cjs/react.development.js +0.23% 90.46 kB 90.66 kB +0.11% 24.34 kB 24.36 kB

Generated by 🚫 dangerJS against dcf04a4

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@josephsavona
josephsavona force-pushed the cache-cleanup-2 branch from db7944f to 4ba534c Compare October 21, 2021 04:12
acdlite
acdlite approved these changes Oct 21, 2021
View reviewed changes

@acdlite acdlite left a comment

Copy link
Copy Markdown
Collaborator

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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/react-reconciler/src/ReactFiberCacheComponent.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@josephsavona
Implement cache cleanup
6fae379
@josephsavona
josephsavona force-pushed the cache-cleanup-2 branch from f2a9fc7 to 6fae379 Compare October 21, 2021 20:15
josephsavona added 2 commits October 21, 2021 13:16
@josephsavona
update snapshot
faf84fe
@josephsavona
wrap new functions in feature flag
dcf04a4
@josephsavona
josephsavona merged commit fa9bea0 into react:main Oct 21, 2021
@aobitoz

This comment has been minimized.

Sign in to view
@gaearon gaearon mentioned this pull request Oct 30, 2021
React 18 - waterfall suspensions re-trigger the Suspense boundary #22626
Open
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Nov 2, 2021
Andrei Shikov @facebook-github-bot
React Native sync for revisions afcb9cd...3fcd81d
e161598
Summary:
This sync includes the following changes:
- **[5cccacd](react/react@5cccacd13 )**: Upgrade useId to alpha channel ([#22674](react/react#22674)) //<Andrew Clark>//
- **[75f3dde](react/react@75f3ddebf )**: Remove experimental useOpaqueIdentifier API ([#22672](react/react#22672)) //<Andrew Clark>//
- **[8c4a05b](react/react@8c4a05b8f )**: Remove flow pragma comment from module registration start/stop templates ([#22670](react/react#22670)) //<Brian Vaughn>//
- **[ebf9ae8](react/react@ebf9ae857 )**: useId ([#22644](react/react#22644)) //<Andrew Clark>//
- **[a0d991f](react/react@a0d991fe6 )**: Re-land #22292 (remove uMS from open source build) ([#22664](react/react#22664)) //<Andrew Clark>//
- **[6bce035](react/react@6bce0355c )**: Upgrade useSyncExternalStore to alpha channel ([#22662](react/react#22662)) //<Andrew Clark>//
- **[7034408](react/react@7034408ff )**: Follow-up improvements to error code extraction infra ([#22516](react/react#22516)) //<Andrew Clark>//
- **[90e5d36](react/react@90e5d3638 )**: chore: fix comment typo ([#22615](react/react#22615)) //<btea>//
- **[3c4c1c4](react/react@3c4c1c470 )**: Remove warning for dangling passive effects ([#22609](react/react#22609)) //<Andrew Clark>//
- **[d5b6b4b](react/react@d5b6b4b86 )**: Expand act warning to cover all APIs that might schedule React work ([#22607](react/react#22607)) //<Andrew Clark>//
- **[fa9bea0](react/react@fa9bea0c4 )**: Initial implementation of cache cleanup ([#22510](react/react#22510)) //<Joseph Savona>//
- **[0e8a5af](react/react@0e8a5aff3 )**: Scheduling Profiler: Add marks for component effects (mount and unmount) ([#22578](react/react#22578)) //<Brian Vaughn>//
- **[4ba2057](react/react@4ba20579d )**: Scheduling Profiler: De-emphasize React internal frames ([#22588](react/react#22588)) //<Brian Vaughn>//
- **[cdb8a1d](react/react@cdb8a1d19 )**: [Fizz] Add option to inject bootstrapping script tags after the shell is injected ([#22594](react/react#22594)) //<Sebastian Markbåge>//
- **[34e4c97](react/react@34e4c9756 )**: Clear extra nodes if there's a hydration mismatch within a suspense boundary  ([#22592](react/react#22592)) //<Sebastian Markbåge>//
- **[02f4115](react/react@02f411578 )**: Upgrade useInsertionEffect to stable ([#22589](react/react#22589)) //<Andrew Clark>//
- **[2af4a79](react/react@2af4a7933 )**: Hydrate using SuspenseComponent as the parent ([#22582](react/react#22582)) //<Sebastian Markbåge>//
- **[b1acff0](react/react@b1acff0cc )**: Enable cache in test renderer ([#22580](react/react#22580)) //<Joseph Savona>//
- **[996da67](react/react@996da67b2 )**: Replace global `jest` heuristic with `IS_REACT_ACT_ENVIRONMENT` ([#22562](react/react#22562)) //<Andrew Clark>//
- **[163e81c](react/react@163e81c1f )**: Support disabling spurious act warnings with a global environment flag ([#22561](react/react#22561)) //<Andrew Clark>//
- **[23b7dfe](react/react@23b7dfeff )**: Enable scheduling profiler for RN FB profiling builds ([#22566](react/react#22566)) //<Brian Vaughn>//
- **[61455a2](react/react@61455a25b )**: Enable experimental Cache API in www TestRenderer ([#22554](react/react#22554)) //<Joseph Savona>//
- **[7142d11](react/react@7142d110b )**: Bugfix: Nested useOpaqueIdentifier references ([#22553](react/react#22553)) //<Andrew Clark>//
- **[1e247ff](react/react@1e247ff89 )**: Enabled scheduling profiler marks for React Native FB target ([#22544](react/react#22544)) //<Brian Vaughn>//
- **[c16b005](react/react@c16b005f2 )**: Update test and stack frame code to support newer V8 stack formats ([#22477](react/react#22477)) //<Brian Vaughn>//
- **[55d7500](react/react@55d75005b )**: duplicate value in variable ([#22390](react/react#22390)) //<BIKI DAS>//

Changelog:
[General][Changed] - React Native sync for revisions afcb9cd...3fcd81d

jest_e2e[run_all_tests]

Reviewed By: yungsters

Differential Revision: D32065987

fbshipit-source-id: ef2d402835c981aab68ca40a894c66c1630864e9
KamranAsif pushed a commit to KamranAsif/react that referenced this pull request Nov 4, 2021
@josephsavona @KamranAsif
Initial implementation of cache cleanup (react#22510)
3f0937b
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.
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Nov 15, 2021
Andrei Shikov @facebook-github-bot
React Native sync for revisions afcb9cd...c0c71a8
55663ec
Summary:
This sync includes the following changes:
- **[c0c71a8](react/react@c0c71a868 )**: Re-enable useMutableSource in internal RN ([#22750](react/react#22750)) //<Ricky>//
- **[cb11155](react/react@cb11155c8 )**: Add runtime type checks around module boundary code ([#22748](react/react#22748)) //<Brian Vaughn>//
- **[a04f13d](react/react@a04f13d29 )**: [email protected] //<Dan Abramov>//
- **[ff9897d](react/react@ff9897d23 )**: [React Refresh] support typescript namespace syntax ([#22621](react/react#22621)) //<irinakk>//
- **[0ddd69d](react/react@0ddd69d12 )**: Throw on hydration mismatch and force client rendering if boundary hasn't suspended within concurrent root ([#22629](react/react#22629)) //<salazarm>//
- **[c3f34e4](react/react@c3f34e4be )**: [email protected] //<Dan Abramov>//
- **[827021c](react/react@827021c4e )**: Changelog for [email protected] //<Dan Abramov>//
- **[8ca3f56](react/react@8ca3f567b )**: Fix module-boundary wrappers ([#22688](react/react#22688)) //<Brian Vaughn>//
- **[1bf6deb](react/react@1bf6deb86 )**: Renamed packages/react-devtools-scheduling-profiler to packages/react-devtools-timeline ([#22691](react/react#22691)) //<Brian Vaughn>//
- **[51c558a](react/react@51c558aeb )**: Rename (some) "scheduling profiler" references to "timeline" ([#22690](react/react#22690)) //<Brian Vaughn>//
- **[00ced1e](react/react@00ced1e2b )**: Fix useId in strict mode ([#22681](react/react#22681)) //<Andrew Clark>//
- **[5cccacd](react/react@5cccacd13 )**: Upgrade useId to alpha channel ([#22674](react/react#22674)) //<Andrew Clark>//
- **[75f3dde](react/react@75f3ddebf )**: Remove experimental useOpaqueIdentifier API ([#22672](react/react#22672)) //<Andrew Clark>//
- **[8c4a05b](react/react@8c4a05b8f )**: Remove flow pragma comment from module registration start/stop templates ([#22670](react/react#22670)) //<Brian Vaughn>//
- **[ebf9ae8](react/react@ebf9ae857 )**: useId ([#22644](react/react#22644)) //<Andrew Clark>//
- **[a0d991f](react/react@a0d991fe6 )**: Re-land #22292 (remove uMS from open source build) ([#22664](react/react#22664)) //<Andrew Clark>//
- **[6bce035](react/react@6bce0355c )**: Upgrade useSyncExternalStore to alpha channel ([#22662](react/react#22662)) //<Andrew Clark>//
- **[7034408](react/react@7034408ff )**: Follow-up improvements to error code extraction infra ([#22516](react/react#22516)) //<Andrew Clark>//
- **[90e5d36](react/react@90e5d3638 )**: chore: fix comment typo ([#22615](react/react#22615)) //<btea>//
- **[3c4c1c4](react/react@3c4c1c470 )**: Remove warning for dangling passive effects ([#22609](react/react#22609)) //<Andrew Clark>//
- **[d5b6b4b](react/react@d5b6b4b86 )**: Expand act warning to cover all APIs that might schedule React work ([#22607](react/react#22607)) //<Andrew Clark>//
- **[fa9bea0](react/react@fa9bea0c4 )**: Initial implementation of cache cleanup ([#22510](react/react#22510)) //<Joseph Savona>//
- **[0e8a5af](react/react@0e8a5aff3 )**: Scheduling Profiler: Add marks for component effects (mount and unmount) ([#22578](react/react#22578)) //<Brian Vaughn>//
- **[4ba2057](react/react@4ba20579d )**: Scheduling Profiler: De-emphasize React internal frames ([#22588](react/react#22588)) //<Brian Vaughn>//
- **[cdb8a1d](react/react@cdb8a1d19 )**: [Fizz] Add option to inject bootstrapping script tags after the shell is injected ([#22594](react/react#22594)) //<Sebastian Markbåge>//
- **[34e4c97](react/react@34e4c9756 )**: Clear extra nodes if there's a hydration mismatch within a suspense boundary  ([#22592](react/react#22592)) //<Sebastian Markbåge>//
- **[02f4115](react/react@02f411578 )**: Upgrade useInsertionEffect to stable ([#22589](react/react#22589)) //<Andrew Clark>//
- **[2af4a79](react/react@2af4a7933 )**: Hydrate using SuspenseComponent as the parent ([#22582](react/react#22582)) //<Sebastian Markbåge>//
- **[b1acff0](react/react@b1acff0cc )**: Enable cache in test renderer ([#22580](react/react#22580)) //<Joseph Savona>//
- **[996da67](react/react@996da67b2 )**: Replace global `jest` heuristic with `IS_REACT_ACT_ENVIRONMENT` ([#22562](react/react#22562)) //<Andrew Clark>//
- **[163e81c](react/react@163e81c1f )**: Support disabling spurious act warnings with a global environment flag ([#22561](react/react#22561)) //<Andrew Clark>//
- **[23b7dfe](react/react@23b7dfeff )**: Enable scheduling profiler for RN FB profiling builds ([#22566](react/react#22566)) //<Brian Vaughn>//
- **[61455a2](react/react@61455a25b )**: Enable experimental Cache API in www TestRenderer ([#22554](react/react#22554)) //<Joseph Savona>//
- **[7142d11](react/react@7142d110b )**: Bugfix: Nested useOpaqueIdentifier references ([#22553](react/react#22553)) //<Andrew Clark>//
- **[1e247ff](react/react@1e247ff89 )**: Enabled scheduling profiler marks for React Native FB target ([#22544](react/react#22544)) //<Brian Vaughn>//
- **[c16b005](react/react@c16b005f2 )**: Update test and stack frame code to support newer V8 stack formats ([#22477](react/react#22477)) //<Brian Vaughn>//
- **[55d7500](react/react@55d75005b )**: duplicate value in variable ([#22390](react/react#22390)) //<BIKI DAS>//

Changelog:
[General][Changed] - React Native sync for revisions afcb9cd...c0c71a8

jest_e2e[run_all_tests]

Reviewed By: yungsters

Differential Revision: D32395873

fbshipit-source-id: 3afd158f167b1eedcc244e29aba1a2c502d3c9d9
zhengjitf pushed a commit to zhengjitf/react that referenced this pull request Apr 15, 2022
@josephsavona @zhengjitf
Initial implementation of cache cleanup (react#22510)
c9abb0a
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.
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@josephsavona
Initial implementation of cache cleanup (react#22510)
d3c4def
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.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@josephsavona
Initial implementation of cache cleanup (react#22510)
e712ad5
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@acdlite acdlite acdlite approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@josephsavona @sizebot @aobitoz @acdlite @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.