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

enforceActions: 'always' stops working in conjunction with isolateGlobalState: true #1869

Closed
5 of 6 tasks
choruk opened this issue Jan 17, 2019 · 4 comments
Closed
5 of 6 tasks
Labels

Comments

@choruk
Copy link

choruk commented Jan 17, 2019

Hello! 👋

I have a:

  1. Issue:
  • Provide error messages including stacktrace
  • Provide a minimal sample reproduction. Create a reproduction based on this sandbox

I created a minimal sample reproduction here: https://codesandbox.io/s/v8kkpjq8x7. If you remove isolateGlobalState: true from the configuration, then the "strict mode" errors start appearing in the console and the timer is no longer incremented. However, with isolateGlobalState: true in the configuration, no "strict mode" errors appear and the timer increments.

  • Did you check this issue wasn't filed before?

I started down this path because we ran into a situation where the "strict mode" errors were only being thrown when two instances of MobX existed on the page (which is only on a subset of pages in our application). Any page that only had one instance of MobX worked just fine (i.e. no "strict mode" errors). I noticed a couple closed issues (#1473 seems like the most relevant), but they all seemed to indicate that the issue was fixed.

We have automated tests covering the code path in our application that was modifying observables outside of an action, but the tests were not failing. I noticed that removing the isolateGlobalState configuration option caused the tests to start to fail, so I decided to see if I could reproduce this issue outside of our application...and here we are 😅

  • Elaborate on your issue. What behavior did you expect?

I expect that if I set enforceActions: 'always' then MobX will always enforce that observables must be modified in an action, regardless of whether isolateGlobalState is enabled or not.

  • State the versions of MobX and relevant libraries. Which browser / node / ... version?

I think you can see this from the code sandbox that I linked. One other data point: if I change the version of MobX in that sandbox to 4.1.0, then everything works as expected. I didn't exhaustively go through all MobX versions to figure out if others work / don't work, but we are using MobX 4.5.0 in our production application where we originally ran into this issue.

@mweststrate
Copy link
Member

Confirmed the bug. Note that having two mobx instances sounds like a potential setup for trouble 😅

@mweststrate
Copy link
Member

Fixed and released in 4.9.0 / 5.9.0

@choruk
Copy link
Author

choruk commented Jan 22, 2019

Thanks for the quick fix!

Note that having two mobx instances sounds like a potential setup for trouble 😅

Haha yea 🙈

@lock
Copy link

lock bot commented Jul 21, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants