Serializer sometimes returns undefined


#1

In some occurrences my application fails because of the following error:

response from a findAll must be an Array, not undefined

Strangely, a simple refresh solves the problem. I have also tracked the error up to the point that the serializer returns undefined. However, when adding a breakpoint there and executing the code myself it does not return undefined. Somehow it seems to be a race condition. We were able to trigger it by logging out of our application and logging back in. Then it always occurs. However, sometimes on a simple refresh it also occurs.

The question: does anyone has an idea what it could be? A starting point for my search would be perfect.


#2

Sounds to me like an observer is firing when that property is set and changing it to undefined.


#3

Fyi: the undefined happens when executing the serializer extract within the pushMany method.

So I would find it strange if an observer has implications at that point but I’ll check it nevertheless.


#4

Can you post snippits of you code. Specifically the findAll function you’re calling, customization to your adapter and serializer, and a mock of the JSON payload?


#5

We’ve solved the problem. The issue was related to synchronous relations and the order in why the API server responded to asynchronous calls. We’ve decided to focus on async relations and as a quick fix we’re using the beforeModel hook to make sure the required models are loaded.