Skip to content

Preserve __proto__ keys in structuredClone - #58217

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

Preserve __proto__ keys in structuredClone#58217
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/fix-structured-clone-proto-key

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary:

The structured-clone polyfill writes enumerable keys through assignment, so an own __proto__ data property mutates the clone's prototype and disappears. Route property writes through one helper that retains ordinary assignment on the common path and uses defineProperty only for this exceptional key across array, fast-object, and slow-object traversal.

Fixes #58216.

Changelog:

[GENERAL] [FIXED] - Preserve own proto data properties and normal prototypes in structuredClone.

Test Plan:

  • Exact Hermes baseline produced no own descriptors and replaced both Object/Array clone prototypes with the property value.
  • Fixed focused Fantom suite: 33/33 passed; own descriptors, ordinary prototypes, and deeply cloned values match native structuredClone.
  • 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.

structuredClone loses own __proto__ data properties

1 participant