jk-gan / redux-flipper

Redux middleware for React Native for Flipper
MIT License
158 stars 21 forks source link

Can some actions run before @@INIT? #73

Open chmac opened 1 year ago

chmac commented 1 year ago

Firstly, thanks a lot for this package and the flipper plugin. It's a godsend to be able to see a history of redux actions again since React Native Debugger no longer works with the hermes engeine.

Edit: Please disregard the rest of this message, I think I found the issue just after posting this!

I think I've noticed something weird. I've been working on the startup process in our app. Scheduling stuff to run only after the app has booted, and so on. It seems to me as if some actions are missing from the flipper log. One guess I have is that these actions are dispatched on the store before expo renders the react part of our app. So at the time of these actions executing, maybe react hasn't started.

I know the actions were dispatched, because if I dispatch a random action, the state has changed from the @@INIT action.

Sorry, I realise this is probably pretty hard to follow. I figured I'd ask the question first, and if you have any insights, go from there. Otherwise I could try to produce a minimal reproduction to show what I mean. But I wanted to check first in case this is somehow a known behaviour, etc.

chmac commented 1 year ago

Ah, wait, maybe my actions are being dispatched before the @@INIT action, could that be it?

chmac commented 1 year ago

Right, so by the time the @@INIT action gets dispatched, my state has already changed, a few actions have dispatched, a few thunks, and my state has mutated quite far from the empty initial state.

Is there any way to invoke that action earlier? Or have I maybe misconfigured something? I put the redux-flipper middleware to the end of the middleware queue, but I guess that's the correct setup... 🤔

chmac commented 1 year ago

I was able to work around this temporarily by wrapping my startup action in a setTimeout(). A delay of 1ms wasn't enough, but 5ms and I can reliably see all my own actions.

plwai commented 1 year ago

I will look into this. this should not happen.