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" in production while dealing with arrays #673

Closed
2 of 3 tasks
bhollis opened this issue Sep 18, 2020 · 10 comments
Closed
2 of 3 tasks

"Maximum call stack exceeded" in production while dealing with arrays #673

bhollis opened this issue Sep 18, 2020 · 10 comments

Comments

@bhollis
Copy link

bhollis commented Sep 18, 2020

🐛 Bug Report

This appears to be similar to, if not exactly the same as #198. I verified that downgrading to version 6.0.9 fixes it, so it may be the same sideEffect declaration in package.json.

I have some state that I'm operating on that's effectively an array of objects (A), each of which has as a property another array of objects (B). In my producer function, I'm modifying properties of those leaf (B) objects, as well as adding them to, and removing them from, the inner arrays (B). For example, I'm deleting an object from one B array (e.g. in A[0]) and adding it to another B array (in A[1]).

Link to repro

To Reproduce

Unfortunately, I haven't managed to reproduce this locally (in node or in browser) or on CodeSandbox. Only our deployed production build had the problem. I was able to verify through Sentry.io that downgrading to v6 stopped this error from happening.

Observed behavior

An infinite recursion leading to "Maximum call stack exceeded", coming from inside the immer code.

Expected behavior

State to be updated or at least an error.

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)

I haven't tried setUseProxies(false) - we only run in environments which use proxies.

@mweststrate
Copy link
Collaborator

mweststrate commented Sep 19, 2020 via email

@mweststrate
Copy link
Collaborator

mweststrate commented Sep 19, 2020 via email

@bhollis
Copy link
Author

bhollis commented Sep 19, 2020

Good suggestions, I'll do those experiments and get back to you.

@cuchac
Copy link

cuchac commented Dec 15, 2021

Hello,
I'm also having this problem. I spent several days trying to fix it and then desperately trying to remove dependency on Immer. Finally I was able to find the cause few days ago:
I use Immer to produce patches and implement undo/redo. These patches I was storing also inside state managed by Immer. And that was the reason. If I store large patch to variable inside Immer produce() function, I sometimes get this error.

@Subha
Copy link

Subha commented Jan 6, 2022

I am also having the same issue and this happens only when i have large items in the page like Grids, when i downgraded to 6.0.9 i do not see the issue. I tested it in multiple browser as well. Like Bhollis reported this looks similar to #198. Can someone please look into this issue or provide a work around?

Thank you

@santiblanco99
Copy link

santiblanco99 commented Sep 26, 2022

Any luck with this issue? The bug is still happening in my case, using v9.0.15. Only happens when the build is set to production mode

@johnjom10
Copy link

Does the array contain something that is self referencing ie, a circular structure?

@carlesandres
Copy link

carlesandres commented Apr 17, 2023

I'm experiencing this with v10.0.1 only in production mode, dev mode is fine.
The same issue happened in v9.
I'm "just" pushing a value to an array. However, the value I'm pushing contains a ReactNode, which I guess is a circular structure, which then classifies as one of the known pitfalls: https://immerjs.github.io/immer/pitfalls/

@mweststrate
Copy link
Collaborator

mweststrate commented Apr 17, 2023 via email

@SCLeoX
Copy link

SCLeoX commented Dec 1, 2024

@carlesandres Thank you so much. This was my exact issue. Thank you for leaving a clear explanation and solution here. 👍

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

No branches or pull requests

8 participants