Help Error: [mobx-state-tree] assertion failed: cannot finalize the creation of a node that is already dead #2225
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hey @xforcarlos - sorry to hear about the trouble. My guess is you've got some kind of asynchronous operations happening somewhere that don't settle before you modify them. Since you're calling That's just a guess though. I could help you a lot more if you're able to create a minimal reproduction? That would be clearer than screenshots of the code, and you might even be able to debug your own issue by trying to take your app logic and distilling it to the smallest possible example where you can reproduce the issue. Looking forward to helping out! |
Beta Was this translation helpful? Give feedback.
-
I think it's the The I think you could resolve this by doing the |
Beta Was this translation helpful? Give feedback.
I think it's the
self.deleteOrder
method you have inafterCreate
(the one that's not insetTimeout
).The
afterCreate
is fired before a node is "finalized" (more of an internal detail, but hopefully that brings clarity to the error message). The problem is that it's gettingdestroy
-ed before that happens, and hence the error message.I think you could resolve this by doing the
deleteOrder
call insetTimeout(..., 0)
, because it will run (roughly) on the next tick of the event loop, after the object has had a chance to finalize.