-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assertion after saving a new relational record and tried to forget it #9229
Comments
might need to pair with you to debug this one. There's things happening here we don't particularly support but the general flow is something we do support. |
I want to add some more context to understand the issue a bit better. I'm using my own CRUD functions inside the store to request data from the backend. I also use my own tracker to track relationship changes (I hope it will be the Ember Data one day). When creating or saving a record I loop over all the changed fields in the model. When a field is a relational field, I go to that model and loop over all those fields as well and continue to do so until we are at the 'bottom'. During this process I build the data structure for the backend. As an example, I have a
I have an existing {
"method": "model.product.write",
"params": [
[4950], <-- actual product id in the backend
{
"supplier": [ <-- hasMany on the product model
["write", <-- changes to an existing record in the backend
[1094], <-- the id of that record
{
"code": "3422",
"price": [ <-- hasMany on the supplier model
["create", <-- create a new record for the price
[
{
"product_supplier": 1094,
"quantity": 10,
"unit_price": 23
}
]
]
]
}
],
["create", <-- create a new record for the supplier
[
{
"code": "Code for supplier",
"name": "Name of product of supplier",
"price": [
["create", <-- create two new records for the new supplier
[
{
"product_supplier": -3,
"quantity": 5,
"unit_price": 10,
},
{
"product_supplier": -3,
"quantity": 10,
"unit_price": 4
}
]
]
],
"product": 4950
}
]
]
]
},
]
} The structure seems a bit weird, but it just works perfectly and the backend return Because I know which records are new, I want to forget them and fetch them again from the backend. So after everything is stored I walk over them and do
|
Ok, I was thinking that I messed up my installation, but as it turned out, the issue existed a bit longer than I expected. I'm not going into the messy details about it, it already took me too much time. I cloned this repo and linked the different packages:
I wasn't able to link the After some rough testing of several commits, I came across commit be9f3a8 which didn't had the error. However the commit above it (3473596) did have the error and is linked to PR #8807. I didn't dig further. |
I was able to narrow it down to the For now, I will keep |
Today I upgraded to the bleeding edge
5.4.0-alpha.22
version and after a small change (replacing the__storeWrapper
with_capabilities
) in my code everything seemed still to work.Creating a new relational record (hasMany) in the store works perfectly well and I can save it successfully to the backend. Because the new record is a relational one (one or more levels deeper then the main record) the backend doesn't return an
id
, just an empty array to let know that everything was successful.So after the successful save action, I walk over the saved records and records with a negative
id
(all new records I create will get a negativeid
) I will forget them by doingthis.identifierCache.forgetRecordIdentifier(identifier)
which worked well in5.5.0-alpha.11
. Then I reloaded the main record with a force reload from the backend so the cache got refreshed.However, somehow this doesn't work anymore and the record with the negative
id
stays in the store. When I reload the main record with it's relational fields I getUncaught (in promise) Error: Assertion Failed: Expected to receive a stable Identifier to subscribe to
. Placing adebugger
shows that the list of records are loaded from the backend including the new one with the rightid
but the record with the negativeid
is also in the list which should have been removed.The text was updated successfully, but these errors were encountered: