orbitjs / orbit

Composable data framework for ambitious web applications.
https://orbitjs.com
MIT License
2.33k stars 133 forks source link

JSONAPI requests take > 30s (and come empty) #551

Closed delkano closed 5 years ago

delkano commented 5 years ago

I'm trying to switch a working Ember project from using Ember-Data to using Orbit.js (via Ember-Orbit). I think I've set up everything correctly (IndexedDB, IndexedDB-Bucket and JSONAPI sources).

My issue is that, when the app tries to query some data, I can see the request firing from the Network tab in the DevTools, but it takes more than 30s and returns nothing at all.

The console shows:

remote pullFail {expression: {…}, options: undefined, id: "0c0863fb-d02c-4e79-a503-fa500c96f12f"} TypeError: Cannot read property 'data' of undefined
    at JSONAPISerializer.deserializeDocument (jsonapi-serializer.js:184)
    at findRecords (query-operators.js:56)

The same request takes a few milliseconds when done manually, as it did with Ember-Data.

I don't know where to start to solve this or even how to get better debug info.

dgeb commented 5 years ago

@delkano That's definitely an unexpected result. It sounds like a deserialization error, so you should verify that your payload is JSON:API compliant.

I'd also recommend simplifying your setup to start, by just setting up a single remote JSONAPISource source and a store, eliminating the IndexedDB source initially. Set up your strategies with blocking: true to further simplify things. And add an EventLoggingStrategy to your coordinator. When this has been added, you'll see events for all sources logged to your console.

You can also review this example ember-orbit project which shows different configurations: https://github.com/cerebris/peeps-ember-orbit

If you're still having issues or questions, feel free to drop by https://gitter.im/orbitjs/orbit.js to ask questions.

delkano commented 5 years ago

Thanks to @dgeb I've found the issue: the Content-Type header was the wrong value (it should be application/vnd.api+json and it was application/json.