vigetlabs / microcosm

Flux with actions at center stage. Write optimistic updates, cancel requests, and track changes with ease.
http://code.viget.com/microcosm/
MIT License
487 stars 29 forks source link

Data clearing issue when using two sibling presenters #518

Open djmccormick opened 6 years ago

djmccormick commented 6 years ago

Is this a feature, bug, or something else? Bug

What is the current behavior? We're using presenters throughout our application. We nest them without problems. Sometimes when we have one presenter with two presenters inside it, though, we notice some strange behavior. If a sibling presenter loads data it'll sometimes completely clear out the state of the other presenter. This usually happens on initial load, and feels like a race case.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/w2m0mang/). I've tried to create a minimal demo of this behavior but haven't been able to reproduce. We've had this pop up in two different large apps we've built over time, and we're at wits end trying to figure it out. The microcosm-devtools don't seem to work anymore, so we haven't had luck debugging with that. We're using react-router, in case that's relevant. Glad to give more information or run tests.

What is the expected behavior? I'd expect the forks to live independently and not be effected by one another.

Which versions of Microcosm is affected by this issue? We're using 12.13.3

nhunzaker commented 6 years ago

Gross!

Are the sibling presenters using patch or reset?

In any case, I'll look into what's up with the devtools.

nhunzaker commented 6 years ago

Looks like we had a dependency that used array.sort(true) to sort keys, which used to be supported in Chrome, but no longer is (as far as I understand the problem).

I sent out a PR to fix that in https://github.com/alexkuz/react-json-tree/pull/108, but I've also shipped a new version of the Microcosm devtools (0.0.5).

Looks like that's propagating on Google's CDN, but you can grab a copy from the release page:

Now to sort out what's going on with the sibling presenters :)

djmccormick commented 6 years ago

@nhunzaker Thanks for your reply and for the debugger update! It works again. It doesn't show enough to have given me insight around our issue, unfortunately.

I'm not sure if we're using patch or reset. I wasn't aware of the distinction until you mentioned it. We're just using presenters, domains, and actions in a pretty standard way.

It does seem like reset behavior, though. It's some kind of race case, because we can see a bunch of data get loaded and rendered, then it clears out suddenly and the page goes blank. I see domains get cleared out even without hitting debuggers I've placed in their handlers and their getInitialState functions.

Do you have any tips for investigating that would help identify the problem?