Skip to content

Fix reentrant structuredClone calls - #58205

Open
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/fix-structured-clone-reentrancy
Open

Fix reentrant structuredClone calls#58205
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/fix-structured-clone-reentrancy

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary:

The structured-clone polyfill reuses one module-global cycle map based on the assumption that cloning invokes no user code. Enumerable getters can reenter structuredClone; the inner call then clears the outer map and breaks later circular references. Pass memory explicitly through recursion, preserve the reusable map for ordinary calls, and allocate an independent map only while reentered.

Fixes #58204.

Changelog:

[GENERAL] [FIXED] - Preserve circular references when a property getter reenters structuredClone.

Test Plan:

  • Exact Fantom baseline: 1 failed / 32 passed (clone.self !== clone).
  • Fixed Fantom suite: 33/33 passed.
  • Fresh yarn flow-check: 0 errors.
  • Targeted ESLint, Prettier, and git diff --check passed.

No UI change; screenshots are not applicable.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 30, 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 Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. 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.

Reentrant structuredClone breaks outer circular references

1 participant