Skip to content

Preserve Error prototypes in structuredClone - #58215

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

Preserve Error prototypes in structuredClone#58215
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/fix-structured-clone-error-prototypes

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary:

The structured-clone polyfill validates standard Error names but always creates a base Error, producing objects whose .name disagrees with their prototype. Map each serialized standard name to its built-in constructor, instantiate that type directly, and retain base Error as the invalid-name fallback.

Fixes #58214.

Changelog:

[GENERAL] [FIXED] - Preserve specialized standard Error prototypes in structuredClone.

Test Plan:

  • Exact Hermes baseline first failed EvalError prototype identity.
  • Fixed focused Fantom suite: 32/32 passed for all seven standard/fallback prototypes, matching 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 specialized Error prototypes

1 participant