You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ran into an unexpected bug last week, which took me some time to dig through, but I think I've noticed a case where prevState is being mutated when state is transformed inside of a store handler.
Here's a screenshot of what's going on:
You can see that logging prevState before invoking the store handler shows one thing, and then logging it after the store handler is called, shows a new prevState.
The second result of prevState, coincides with what state should look like after currState is handled inside of the store, so this sounds like a pointer problem to me.
Eventually prevState === this.__state evaluates to true, so no change observers are notified and my app doesn't update despite an action being sent into the system.
Can you reproduce this in the context of only ImmutableJS? I was under the impression that withMutations doesn't affect the current thing, but instead creates a mutable copy that can be returned.
@jordangarcia that's my understanding of withMutations as well.
Unfortunately, was not able to repro just with Immutable. Here's a fiddle, which (I believe) works the same way Nuclear does: https://jsfiddle.net/6Lucnaj3/
I will be releasing 1.2 in the next couple of days, it should fix this behavior as __notify will no longer be conditional on state equality, but rather if any store has changed since last notify.
Ran into an unexpected bug last week, which took me some time to dig through, but I think I've noticed a case where
prevState
is being mutated whenstate
is transformed inside of a store handler.Here's a screenshot of what's going on:
You can see that logging
prevState
before invoking the store handler shows one thing, and then logging it after the store handler is called, shows a newprevState
.The second result of
prevState
, coincides with what state should look like aftercurrState
is handled inside of the store, so this sounds like a pointer problem to me.Eventually
prevState === this.__state
evaluates totrue
, so no change observers are notified and my app doesn't update despite an action being sent into the system.For reference here's my handler:
As you can see no direct mutations going on. Adding an
asImmutable
call before returning state, however, prevents the bug:So, somewhere along the way, state is being mutated, possibly inside of
Store#handle
, but haven't had enough time to really investigate.Want to be upfront that I'm using a previous version of Nuclear because of #141
The text was updated successfully, but these errors were encountered: