Skip to content

docs: note exception-safe cleanup of JS Yoga trees#1999

Open
greekr4 wants to merge 1 commit into
react:mainfrom
greekr4:docs-js-tree-cleanup
Open

docs: note exception-safe cleanup of JS Yoga trees#1999
greekr4 wants to merge 1 commit into
react:mainfrom
greekr4:docs-js-tree-cleanup

Conversation

@greekr4

@greekr4 greekr4 commented Jul 22, 2026

Copy link
Copy Markdown

Summary

The JavaScript docs already warn that nodes must be freed manually, but don't mention two things we ran into in production (a WASM-based canvas editor that builds a throwaway Yoga tree per layout pass):

  1. Nodes live in the WebAssembly heap, so leaked nodes are invisible to the JS garbage collector and accumulate until Node.create() fails.
  2. If a measure function (or any code between create and free) throws, the whole tree leaks unless freeing happens in a finally block.

This adds a short paragraph and a try/finally example to the existing warning in the JavaScript tab of "Laying out a Yoga tree".

Test Plan

Docs-only change. Verified the MDX renders (admonition + code fence) and the relative link to external-layout-systems.mdx resolves.

@meta-cla meta-cla Bot added the CLA Signed label Jul 22, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant