Error: You may not call store.getState() while the reducer is executing

I keep getting this error on iOS Preview App as shown below, and it leads to unpredictable crashes when continuing to use the app. Could somebody please explain?

27 May 10:38:08 - [error] [function2:864f9da9.ae2128] Error: Reducers may not dispatch actions.
Failed to evaluate an expression 'FIND_BY_KEY(LOOKUP(LOOKUP(LOOKUP(appVars,"data"),"orders"),"records"),"objectId",LOOKUP(params,"objectId"))': You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store. 
Failed to evaluate an expression 'FIND_BY_KEY(LOOKUP(LOOKUP(LOOKUP(appVars,"data"),"orders"),"records"),"objectId",LOOKUP(params,"objectId"))': You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store. 
Failed to evaluate an expression 'FIND_BY_KEY(LOOKUP(LOOKUP(LOOKUP(appVars,"data"),"orders"),"records"),"objectId",LOOKUP(params,"objectId"))': You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store. 
27 May 10:37:43 - [error] [subflow:own_23268044.e1e2b:9ecffbd0.227388] Error: You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.

Hi @Juan_Giraldo, are you still getting these errors, were you able to narrow down if they were tied to any particular action you make in the app?

Hey @Mari, it’s not possible for me to know with full certainty since I don’t know the internals, but it seems like the issue was being caused by setting different properties of the same object variable in parallel.

To give more details, I had three API calls being called on a Page Mounted event which would write their results to a corresponding property of the same app variable. The data retrieve from all three calls was quite small (>50 results), and the flows for each operation were inside the logic canvas of each data variable.

I put a consecutive delay on two of the operations (so 0ms, 500ms and 1000ms respectively) and for now that seems to have resolved the issue. As a curiosity, the orders property of data (the app variable) was the last to show in the UI as it is displayed in alphabetical order (not sure if related?)

Hope that helps to find the issue, unfortunately it caused us to waste a lot of time until we found the current fix described above.

1 Like