I am in the process of upgrading Ember and Ember Data to 1.13.x. I switched to using the new JSON API adapter/serializer and also changed the server response to conform the JSON API format. However I am having problem with an error handling scenario. A model gets properly updated when following the happy path but when the update needs to fail because say optimistic lock detects simultaneous updates then I have the model stuck in "inFlight" state.
This is an example request:
{
data: {
id: "1",
type: "books",
attributes: {
name: "New Book Name",
version: 1
}
}
}
The server finds out that the current version is greater than 1 and rejects the update with 409 HTTP status code and the response is:
{
errors: [{
code: "2",
detail: "Simultaneous changes.",
source: {
pointer: "data"
},
status: "409"
}]
}
The problem is that after the server response my model is in "root.loaded.updated.inFlight" state. Even after calling model.rollbackAttributes() the state doesn't change.
Is this a problem in the server response JSON? Is this a bug in Ember Data?
Feedback is appreciated.
Aucun commentaire:
Enregistrer un commentaire