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

[minor] Add failing test for nested and chained produce calls #935

Merged
merged 2 commits into from
Jan 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions __tests__/regressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,25 @@ function runBaseTest(name, useProxies, autoFreeze, useListener) {
baz: undefined
})
})

test("Nested and chained produce calls throw 'Cannot perform 'get' on a proxy that has been revoked' error", () => {
const state = {
foo: {
bar: {
baz: "banana"
}
}
}
const newState = produce(state, draft => {
draft.foo = produce(draft.foo, fooDraft => {
fooDraft.baz = fooDraft.bar.baz.replace("banana", "apple")
})
draft.foo = produce(draft.foo, fooDraft => {
/* another produce call makes this fail */
/* no actual mutation necessary to make this happen */
})
})
JSON.stringify(newState)
})
})
}