Skip to content

Reentrant structuredClone breaks outer circular references #58204

Description

@OskarEichler

Description

The React Native structuredClone polyfill reuses one module-global memory map under the assumption that cloning does not invoke user code. Enumerable property getters do execute, however, and can call structuredClone recursively. The inner call's finally clears the outer clone's memory, so later circular references are cloned again instead of pointing to the outer result.

Expected behavior

Each reentrant clone should have independent cycle-detection memory, while ordinary non-reentrant calls may retain the existing reusable-map optimization.

React Native Version

0.87.1 and current main

Affected Platforms

JavaScript runtime - All

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions