Skip to content
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

fix: Environment with no FinalizationRegistry #7885

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

snowystinger
Copy link
Member

Closes #7882

We thought we could safely use this as every environment supports it
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry
https://caniuse.com/?search=FinalizationRegistry

But it's not supported in CloudFlare workers. In that case though, every request should result in the complete throwing away of any previous request making the memory leak a non-issue.

If any other environments come along without this feature, they'll also have the problem, but given how long it took for it to be reported, maybe it's not that big of a deal.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@rspbot
Copy link

rspbot commented Mar 7, 2025

idsUpdaterMap.delete(heldValue);
});
let registry;
if (typeof window !== 'undefined' && window.FinalizationRegistry) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to have a window? Some server environments might also have FinalizationRegistry but not have a window. Any problem with doing this?

Suggested change
if (typeof window !== 'undefined' && window.FinalizationRegistry) {
if (typeof FinalizationRegistry !== 'undefined') {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FinalizationRegistry in @react-aria/utils 3.28.0 is unsupported in Cloudflare Workers environment
3 participants