Skip to content

produce leaks proxy objects when symbols are present #1087

@dhmk083

Description

@dhmk083

🐛 Bug Report

When you use produce on an object which contains a symbol property which is an object, it leaks Proxy object into returned value.

Link to repro

https://codesandbox.io/p/sandbox/suspicious-sanne-2ypqwt

To Reproduce

  1. Get an object with symbol:
const sym = Symbol()

let state = {
  id: 1,
  [sym]: {} // must be an object
}
  1. Use it with produce and read state[sym] value inside draft function. In returned value state[sym] object will be a revoked proxy instead of plain object.

  2. Use it with produce again. Now an error will be thrown because state[sym] is corrupted.

TypeError
Cannot perform 'getPrototypeOf' on a proxy that has been revoked

Observed behavior

Proxy object is leaking out of produce function.

Expected behavior

Plain object should be returned instead.

Environment

The bug appears since 10.0.0 version. It works fine in 9.0.21 version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions