Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot perform 'get' on a proxy that has been revoked #53

Closed
hex13 opened this issue Jan 10, 2018 · 7 comments
Closed

TypeError: Cannot perform 'get' on a proxy that has been revoked #53

hex13 opened this issue Jan 10, 2018 · 7 comments
Labels

Comments

@hex13
Copy link

hex13 commented Jan 10, 2018

Node: 8.4.0
immer: 0.5.0

const produce = require('immer').default;
const result = produce(
    {arr: [{count:1}, {count: 2}, {count: 3}]},
    draft => {
        draft.arr = draft.arr.filter(item => item.count > 2);
    }
);

console.log(result); // throws

result.arr[0].count seems to be troublesome, even referencing to this variable throws an error.

Result of function produce should be a plain JS object, right? Because it seems that the result sometimes contains proxies inside.

@mweststrate
Copy link
Collaborator

Result of function produce should be a plain JS object, right?

Correct. Interested in creating a PR with a test for the bug?

@zhw2590582
Copy link

zhw2590582 commented Jan 11, 2018

function finalize(base) {
    // console.log(base, base[PROXY_STATE], isProxy(base))
    if (isProxy(base)) {
       // ...
    }
    return base
}

In this case, finalize function is executed twice.
If base is a proxy object, isProxy(base) is true.

State { arr: [ State { count: 3 } ] }

If base is a proxy array, base[PROXY_STATE] is undefined ???
So isProxy(base) is false, and return a proxy.

[ State { count: 3 } ]

I think you should first determine the type of object, as before, right?

function finalize(base) {
   if (isPlainObject(base)) return finalizeObject(base)
   if (Array.isArray(base)) return finalizeArray(base)
   return base
}

@mweststrate
Copy link
Collaborator

Bug confirmed, fix WIP

@mweststrate
Copy link
Collaborator

Fixed in 0.6.1

@nickserv
Copy link

I think I found a regression in 1.1.1, but it's working again in 1.1.3.

@kikill95
Copy link

I've reproduced this issue in 1.7.1

@mweststrate
Copy link
Collaborator

@kikill95 cool. Please open a new issue with reproduction. Responding to closed issues is generally pointless :).

@immerjs immerjs locked and limited conversation to collaborators Jan 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants