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

"Maximum call stack exceeded" with circular references #1106

Open
1 task done
joshkel opened this issue Mar 11, 2024 · 5 comments
Open
1 task done

"Maximum call stack exceeded" with circular references #1106

joshkel opened this issue Mar 11, 2024 · 5 comments
Labels

Comments

@joshkel
Copy link
Contributor

joshkel commented Mar 11, 2024

🐛 Bug Report

Starting with Immer 10.0.4, if Immer is given an object that uses symbols for circular references, it generates a "Maximum call stack exceeded" error.

Link to repro

https://playcode.io/1794809

To Reproduce

Pass an object with pre-existing symbol circular references to Immer 10.0.4. (Circular references that are added within an Immer recipe do not cause problems.)

Observed behavior

"Maximum call stack exceeded"

Expected behavior

Our application uses symbols to create child-to-parent relationships. Since symbols are skipped by many JavaScript routines (e.g., JSON.stringify, Immer prior to 10.0.4), we had been able to do this without error.

Environment

  • Immer version: 10.0.4
  • I filed this report against the latest version of Immer
@mweststrate
Copy link
Collaborator

mweststrate commented Mar 11, 2024

Argh, the JS world is impossible. 50% is like "non-enumerables and proxies have very specific meanings", and the other half is like "I expect non-enumerables and symbol to work just like the rest, why treat them irregularly" 🤣

@mweststrate
Copy link
Collaborator

Would you mind trying setting the setUseStrictShallowCopy(false) flag? Maybe in combination with version 10.0.4-beta?

@joshkel
Copy link
Contributor Author

joshkel commented Mar 11, 2024

@mweststrate I get it. I apologize for contributing to your pain as an open-source maintainer.

setUseStrictShallowCopy(false) with 10.0.4 or 10.0.4-beta seems to have no effect.

For what it's worth, Immer 9.x's behavior seemed consistent and worked for my purposes:

Hopefully that's too ad hoc / too much of a special case - but, if you decide it is, I understand.

@NMinhNguyen
Copy link
Contributor

NMinhNguyen commented Mar 18, 2024

Another way to reproduce this is trying to modify an object that contains React context: https://codesandbox.io/p/devbox/festive-gagarin-9mkfx9

For what it’s worth, the repro seems to work using [email protected]

@mweststrate
Copy link
Collaborator

Yeah I guess the only way to deal with this is to make all the behavior of irregular properties of any kind (enumerable x getter x proxy) all configurable. That will be a a bit bigger project though so probably more for a next major.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants