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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomic set+delete on Map produces incorrect patches #876

Closed
3 tasks done
jscheid opened this issue Dec 3, 2021 · 0 comments
Closed
3 tasks done

Atomic set+delete on Map produces incorrect patches #876

jscheid opened this issue Dec 3, 2021 · 0 comments

Comments

@jscheid
Copy link
Contributor

jscheid commented Dec 3, 2021

馃悰 Bug Report

Hi, big fan of immer here! I think I've found a small issue though:

When adding an element to an object ({}) and then immediately removing it (via applyPatches), produceWithPatches returns an empty patch set as expected, since ultimately nothing has changed.

When doing the same with a Map however, the reported resulting patch set contains only a patch for removing the element. Replaying that patch set (or replaying the reverse patch set on top of the produced result) would produce inconsistent results.

Link to repro

https://codesandbox.io/s/immer-addthenremovepatches-for-map-d4jve?file=/tests/immer.test.ts

To Reproduce

Steps to reproduce the behavior: see repro.

Observed behavior

The resulting patches are different depending on whether the changes were applied to an object or a Map.

Expected behavior

I'd expect the patches to be the same in both cases. At least, I'd expect the patches resulting for Map to be consistent -- for example, an add patch followed by a remove patch.

Environment

We only accept bug reports against the latest Immer version.

  • Immer version:
  • I filed this report against the latest version of Immer
  • Occurs with setUseProxies(true)
  • Occurs with setUseProxies(false) (ES5 only)
jscheid added a commit to jscheid/immer that referenced this issue Dec 3, 2021
jscheid added a commit to jscheid/immer that referenced this issue Dec 3, 2021
@jscheid jscheid changed the title Add+remove against Map produces incorrect patches Atomic set+delete on Map produces incorrect patches Dec 3, 2021
jscheid added a commit to jscheid/immer that referenced this issue Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant