-
-
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
TypeError: Cannot read property 'eachAttribute' of null (store.unloadAll bug?) #4963
Comments
I'm having the same problem. |
@NagiTs thank you, but is workaround :) |
Out of curiosity. What version are you using? Is it the newest 2.13? |
Yes, ember-cli/ember/ember-data 2.13.
A similar bug was fixed in #2870 (#3296 (comment)) 2 years ago. |
Same here, upgraded to 2.13 from 2.10 and encountered this bug :/ |
@NagiTs: not sure I quite follow your steps for the workaround. Would you be able to elaborate a bit more please? |
this.store.unloadRecord(rec);
Ember.run.schedule('destroy', this, function() {
this.store.findRecord('my-model', 1);
}); |
My application was suffering from this too. I was manually unloading some records that appear to have been inflight to work around #3084. Once I removed the manual unloading, everything went back to normal. |
Confirm. This has popped up since upgrading from 2.12 to 2.13. The workaround #4963 (comment) did work for me. Wonder if this.store.unloadRecord(rec).then(() => {
return this.store.findRecord('my-model', 1);
}); |
I'm having this same issue, although I am not explicitly attempting to fetch a new record afterwards. |
We had same issue. Downgrading to 2.12.0 is an alternative solution until this is fixed |
One more use case, failing test - raido@b1f026e |
https://github.com/raido/ember-data-unloadAll-regression - this is basically the same as the unit test case I posted before, except one can easily test with different ED versions against the test case. |
Got the same issue with |
We extend store service as workaround: import Ember from 'ember';
import StoreService from 'ember-data/store';
const {RSVP, run} = Ember;
export default StoreService.extend({
unloadAll() {
const args = arguments;
return new RSVP.Promise(resolve => {
this._super(...args);
run.schedule('destroy', this, function() {
resolve();
})
})
}
}); Thx @NagiTs and @simonihmig for idea. |
+1 having this same issue. Seems a recent unloading records change is causing numerous regressions. |
yeah, maybe #4986 has the same root cause |
closes TryGhost/Ghost#8307 - Ember 2.13 has a behaviour change to `store.unloadAll` where the records aren't removed until later in the runloop resulting in errors if the store is used to find records before it's completed. See emberjs/data#4963
closes TryGhost/Ghost#8307 - Ember 2.13 has a behaviour change to `store.unloadAll` where the records aren't removed until later in the runloop resulting in errors if the store is used to find records before it's completed. See emberjs/data#4963
We are experiencing both this issue and #4986. Based on my own digging, I believe to both be related |
How we could get more attention on this? |
I have same issue. |
We are experiencing this too, plus I believe also #4986, and have seen another exception that would appear to be closely related, but doesn't match exactly. The further example is visiting route A which loads up a lot of records using a complex query, leaving it for route B, whereby the |
This is still failing. |
Also this: raido@12d6984 basically it the same as previous comment just in unit test form. |
So I can confirm that #5011 does fix this with regards to the
Edit: After much more research and digging, I can confirm that this issue is fixed. The other issue I mentioned in this comment was ultimately caused by the issue described in #4986. The error was being caught and it caused this other issue to surface. So nothing to see here, once #4986 is fixed I should be 👍. |
Facing similar problem. Is the bug fixed in ember version 2.14.0 ? |
Just a note in case it helps anyone. I was having this issue in some of my acceptance tests, turned out to be I hadn't built all of the relationships correctly in mirage. It was thrown when a record referenced in one model was not returned by the (fake) API. |
We are still having this issue in 2.16.0-canary (
It works fine with Ember data 2.12. Offending code: items.forEach((item) => this.store.unloadRecord(item)); Where items are the child in a hasMany relationship. Basically as per #4986 Thoughts? |
Not that this is your problem but I've always found I have to add a toArray() in order to avoid mutating the collection I'm forEach()'ing over.
… On Jul 31, 2017, at 5:50 PM, Adam Reis ***@***.***> wrote:
We are still having this issue in 2.16.0-canary (master), so it doesn't seem like #5011 fixed this for all cases.
Assertion Failed: Cannot call get with 'isNew' on an undefined object.
Followed by
TypeError: Cannot read property 'eachAttribute' of null
at new Snapshot (-private.js:5111)
It works fine with Ember data 2.12.
Offending code:
items.forEach((item) => this.store.unloadRecord(item));
Thoughts?
cc @runspired @stefanpenner
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@Kilowhisky thanks, but that was not the issue here. |
@Kilowhisky now that you have brought that up I'm going to investigate it a little further. Never considered the possible mutation. |
Does this bug has been fixed in Ember v2.15.1 ? |
still seeing this in 2.14.10 |
My workaround is to destroy the record before unloading it: // fails
record.unloadRecord()
// works
record
.destroyRecord()
.then(() => {
record.unloadRecord()
}) Also, we're applying this fix after unloading: #5041 (comment) |
Ember 2.13.2 record.destroyRecord()
.then(() => doSomething())
.catch(reason => {
if (reason && reason.errors && reason.errors[0] && reason.errors[0].status === '404') {
record.unloadRecord();
}
}); But this code throws an error only if I have some reverse relations in my Ember models. let ModelOne = DS.Model.extend({
models: DS.hasMany('model-two')
});
let ModelTwo = DS.Model.extend({
owner: DS.belongsTo('model-one')
}); I cannot update the project right now due to some dependencies. |
@Devoter I don’t think this going to be addressed. There have been numerous unload issues on version of ember data past 2.12. Some small issues were addressed but not much. This is what I suggest (since I have too) to pin your project at 2.12. |
Similar issue here :/ pinning to 2.12 for now |
@armiiller @tylerturdenpants @Devoter did you try the current release, ie 3.0.1 ? |
@sly7-7 - I'll try it out later this afternoon. Have you noticed any other side affects from jumping a major release? |
@armiiller For the moment, not at all. All 💚 |
@sly7-7 I cannot try the current release due to third party dependencies of my project. |
@Devoter Not even ember-data 2.18.1 ? If yes, it also has the fix, otherwise I'm just sad for you, I don't have any idea how to workaround this bug. |
I'm getting this in ED 3.0.2 |
Hi! I had error for this code:
Error:
ember-data LOC
Repo for reproduce (ember-twiddle down?)
I can be wrong, but it seems that
this._isDematerializing
inInternalModel
should be equal to false after callstore.unloadAll
method.The text was updated successfully, but these errors were encountered: