Skip to content

Add compat flag docs for FinalizationRegistry and WeakRef #20668

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

Merged
merged 3 commits into from
May 6, 2025

Conversation

ketanhwr
Copy link
Member

Summary

Add docs for WeakRef compat flag.

Screenshots (optional)

Documentation checklist

Copy link
Contributor

Howdy and thanks for contributing to our repo. We review internal PRs within 1 week. If it's something urgent or has been sitting without a comment, start a thread in the Developer Docs space internally.

Copy link
Contributor

hyperlint-ai bot commented Mar 10, 2025

Howdy and thanks for contributing to our repo. The Cloudflare team reviews new, external PRs within two (2) weeks. If it's been two weeks or longer without any movement, please tag the PR Assignees in a comment.

We review internal PRs within 1 week. If it's something urgent or has been sitting without a comment, start a thread in the Developer Docs space internally.


PR Change Summary

Added documentation for the compatibility flags related to FinalizationRegistry and WeakRef.

  • Introduced documentation for the enable_weak_ref and disable_weak_ref flags.
  • Provided explanations for FinalizationRegistry and WeakRef functionalities.
  • Included notes on the behavior and caution regarding the non-deterministic nature of these APIs.

Added Files

  • src/content/compatibility-flags/js-weak-refs.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@ketanhwr ketanhwr force-pushed the ketan/add-js-weak-ref branch from aca3e3e to 68ed6c7 Compare March 10, 2025 12:58
Copy link
Contributor

@irvinebroque irvinebroque left a comment

Choose a reason for hiding this comment

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

Do we have an example, and an example use case that we could share as part of this?

Def changelog worthy, esp if we help people connect the dots to what this makes possible w/WASM @mikenomitch

@ketanhwr
Copy link
Member Author

ketanhwr commented Mar 10, 2025

We can definitely mention that wasm-bindgen and Emscripten optionally use FinalizationRegistry for wasm memory cleanup, but it's part of the generated shim and a user would hardly need to interact with it directly. Not sure if adding an example is helpful here really

@irvinebroque
Copy link
Contributor

It improves memory management for workers-rs, right? That seems like a story right there?

@ketanhwr
Copy link
Member Author

Will definitely improve memory management for all wasm users frankly, not just workers-rs :)

@irvinebroque
Copy link
Contributor

Awesome - let's tell the story and explain! @mikenomitch

@ketanhwr ketanhwr force-pushed the ketan/add-js-weak-ref branch from 68ed6c7 to 6c652c3 Compare April 22, 2025 22:09
Copy link
Contributor

@irvinebroque irvinebroque left a comment

Choose a reason for hiding this comment

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

Are we going to write a changelog entry for this?

https://developers.cloudflare.com/changelog/

And show examples? Or explain what this means for workers-rs?

@ketanhwr
Copy link
Member Author

Are we going to write a changelog entry for this?

https://developers.cloudflare.com/changelog/

And show examples? Or explain what this means for workers-rs?

@danlapid @mikenomitch what do you think? We can certainly mention this in workers-rs or "Rust" section of workers docs. We can possibly have a changelog mentioning improvement in wasm interop/memory usage, but I don't think we want to explicitly advertise the FinalizationRegistry API.

@ketanhwr ketanhwr requested review from a team as code owners April 24, 2025 13:19
@ketanhwr
Copy link
Member Author

@irvinebroque @mikenomitch let me know if this looks good, the compat date is due soon so I'd want this to be available in docs before that

Copy link
Contributor

@mikenomitch mikenomitch left a comment

Choose a reason for hiding this comment

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

Approved to unblock, but added a suggested change to changelog

@ketanhwr ketanhwr merged commit 3e3448c into cloudflare:production May 6, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants