-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Why am I getting an invalid action stack
error?
#2135
Comments
I would guess its related to #2117 |
Do you have multiple mobx versions? |
I can confirm 2 separate instances of this error halting development at my firm, and we had to roll back to @xaviergonz, I am curious the reason for adding this severe of an error in a patch release. If the only reason is to support advanced (framework-level) use of startAction/endAction as discussed in the linked issue, then I would argue it should never break during any first class API usage and the risk of breakage isn't necessarily worth the niche upside for framework developers. If the reason is to catch misuse of first class API usage, then heads up that there are hard to debug edge cases out in the wild (including two separate apps in my firm), and we did not expect to land a dev-breaking debug-heavy issue on a patch version. |
In theory that error (which I added as it was suggested to me here btw: #2117 (comment) ) should never happen when not using those functions directly, but it is true I didn't think of multiple mobx versions sharing the global state (where the new version would update the current action id and the other won't). I'll create a patch that rather than reusing the global state will use their own local state, though it would be cool if somebody could produce a minimum reproduction code. |
@xaviergonz note that the globalversion object has a version number, that is intended to be used to remain backward compatible / it will warn if there are multiple version of mobx sharing incompatible versions of global state. That being said @spark1031; having multiple versions is in most cases a sign of an incorrect package setup, so unless there is an explicit reason why you need multiple versions (the only case I know: having external parties writing plugins for your product that can have their own mobx), the best thing to do is to make sure you have only one version of mobx. It will make your bundle smaller as well. Usually this is caused by using npm link, or by using dependencies that have mobx as dependency instead of as peer dependency. |
Yarn offers a good option to deduplicate different library versions. In package.json add, for example, following and all packages will be forced to use that version and there will be only one sitting at the root of node_modules.
|
Also using yarn-deduplicae can help in many cases |
Thank you so much for your help everyone!! Really appreciate the time everyone took to help explain what might be going on for me and also really appreciate the new update =) Thank you again! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions. |
Context:
I am trying to run some jest/react-testing-library tests with drone and get this error when the test tries to render my component.
Error message: "[mobx] invalid action stack. did you forget to finish an action?"
My component renders some data that is being loaded into a store via mobx. Every time this store is created, the
load
action is called inside the store's constructor. Every time thisload
action is called, the test fails. However, there are no errors that arise when I run my app and no errors that arise when I run my tests locally. This error only occurs when I run my tests in drone.This error seems to originate from here:
https://github.com/mobxjs/mobx/blob/master/src/core/action.ts#L88
Which uses mobx globals which are defined here: https://github.com/mobxjs/mobx/blob/master/src/core/globalstate.ts#L157
Question:
What are some things I could try that could fix this issue? I tried looking on stackoverflow and had little luck finding others who had run into this issue :(
Hopefully someone can help me here!
Thank you in advance!
The text was updated successfully, but these errors were encountered: