-
-
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
Cannot update watchers for model after it has been destroyed #5387
Comments
Using the latest ED still has the problem. I've narrowed down the scenario a bit now (Twiddle) |
@amk221 did you try against @runspired's branch |
I don't think it's fixed it for my use case. I set up an example repo, and |
It's interresting, it seems like there are some timing issues, or maybe a problem with the routing process. I tried to unload the record directly in the model hook, and return it. Weird enough then, the record is not |
|
@amk221 could you elaborate on how you used |
@erichonkanen Originally put the |
Using
We are executing Our current workaround has been to use Before
After
|
Hi, |
I'm having a similar problem here, reproduced in this twiddle: Click "Add Inner" twice I don't know how to use ember inspector with a twiddle, but in my app it looks like I'm getting PromiseManyArray with length 1 and no entries (or an undefined entry, hard to tell) Also note that you can never unload more than two inners - it just keeps claiming to unload the same lastObject after that. |
A work around would be really handy. It's weird issues like these that me really frustrated when using ember-data. |
One weak workaround I've found (though still testing for success) is to not use Ember.computed.filterBy and similar 'reduce computed' array functions. Especially if the value you are sorting or filtering on doesn't change, then you can probably get away with something like:
instead of: Edit: Of course, this doesn't work if the value you're filtering on can change - only if the value is constant and the containing objects are simply added to or removed from the array |
So it turns out my problem was that I had an inverse relationship, and unloading a hasMany item of an inverse relationship doesn't unload cleanly. I overrode 'unloadRecord' of my hasMany target model to be the following:
as shown in this updated twiddle That seems to have solved my problem. Note that store.unloadRecord() simply calls model.unloadRecord() so it handles both situations. unloadAll does not use model.unloadRecord so may still cause the same problem, but it's a significantly different code path . |
Facing lot of issues including watchers issue, cannot find a new tag once model is destroyed, hasMany/belongsTo relationships issue when unloadAll is being used for the model. Is there any release/fix version planned which will have a solution to above issues as workarounds tend to fail in some or another scenario. |
Also would be really helpful, to have suggestions if anyone successfully downgraded to Ember data 2.12 with Ember-cli > 2.18. |
@amk221 thank you for posting this demo app; it was helpful demonstrating this actually is not an ember-data bug. |
After having gone through the reproduction I'm going to close this issue as it seems fairly clear to me that at least in the reproduction the fault lies with app code. The discord thread linked by @efx above in which I discuss this is a good starting point if you want a deeper explanation, but a couple of key take-aways:
|
This recommendation has fixed a case where we experienced this problem. |
In an app with some more complexity, the mentioned workarounds aren't sufficient. Here is how I ended up fixing the issue: model(params) {
return this.store.findRecord('mymodel', params.mymodel_id, { reload: true }) resetController(controller, isExiting) {
this._super(...arguments)
controller.set('model', null) I'm not sure why, it was a last-ditch attempt, but it works. |
@Redsandro Did you do that instead of or in addition to using |
@e-monson To my own surprise, I did it instead of and it worked. Full disclosure: I added it in an attempt to fix my issue. Which worked. Then I removed all the fixes mentioned here. And it still worked. So the net result is the above. |
I just want to chime in and say that this "Cannot update watchers" change is causing us a lot of pain during our upgrade attempt. I understand it's probably for the best and likely due to some bad practices on our end, but we're having a really hard time tracking down the exact causes of this in our code. In our case, we have a bunch of nested routes, controllers, templates, and components (legacy app 👍) that rely on the computed properties of a record that gets unloaded due to a web socket event. We've ended up triggering a custom One thing that would make this easier to deal with is clear error messages that tell us exactly where we can find the offending watchers (template/computed property). As it stands, we are just sifting through stack traces and commenting things out. Feel for anyone else going through this - it's a real pain 😔 |
Oh yes please would love this. I have some small projects where I just couldn't find the cause, too. I've simply removed some functionality because I don't have time to do the trial and error. The |
When exiting a route, I need a specific model to be unloaded from the store.
However, if I then try to refresh the route, I get the error
Here is an example Twiddle:
https://ember-twiddle.com/dfff8b960e58063511927f2768dd7b7c?openFiles=routes.application.js%2C(Trying to come up with a better example)
The only other mention to this error I found was #5111. (But I don't know enough to say if it is related)
The text was updated successfully, but these errors were encountered: