-
-
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
Computed properties dependent on async relationships do not recompute when the relationship fulfills #7904
Comments
@kategengler we encountered widespread issues after upgrading to 3.28. Can confirm it is the same issue with computed properties on async relationships and that it worked through 3.27 and no longer works in 3.28. It is definitely Ember Data since our CP's work fine with Ember CLI 3.28 and Ember Data 3.27. I see nothing in the release notes indicating any intended changes around this. Would be great to hear from the team on this! |
Same for our codebase, I ran into this same issue and actually resolved it by adding dependent keys like For normal CPs adding an extra dependent key to work around this issue was relatively doable, but this issue also affect computed macros. For example One way to work around this issue is turning all classic code with computed properties into Ember Octane with tracked properties etc, but we still have hundreds of components, models, controllers, etc that use computed properties, so converting those takes time. Until we manage to have everything converted, this issue is blocking for us, so we'd like to hear from you too! |
@robinborst95 In my case, adding |
Hm, that is strange 🤔 We also use |
@kategengler Did you find a solution? Adding |
My solution is to access @computed('replies.@each.id')
get numReplies() {
let _ = this.replies.isFulfilled;
return this.hasMany('replies').ids().length;
} |
I found using |
I think the underlying issue here is that |
Found a fix, I think the underlying issue is computed chains check length but don't recompute based on it, they need the fake |
@kategengler @runspired I've tried out the 3.28.10 patch release and it does work for To demonstrate this, I've forked the same Adding Edit: I've tried to adapt the test added by #7945 in a way that also |
Reproduction
Reproduced here https://github.com/kategengler/datatest
With branches for 3.27 (working) and 4.2.0-beta.0 (not working)
Description
A computed property dependent upon an async relationship does not recompute when the relationship fulfills.
In the reproduction, post
hasMany
(async) comments whichhasMany
(async) authorshttps://github.com/kategengler/datatest/blob/main/app/models/post.js#L11-L18 is the computed property, it is referenced in
application.hbs
where the model is a single Post.In the console, you will see that the comments are fetched and the
authors
computed property is only run once, during whichcomments.isFulfilled
isfalse
.If you uncomment
comments.isFulfilled
as a dependent key on the CP, you will see it run twice, once when it is fulfilled, and authors are fetched via the API, but still the authors do not list in the template.In the template, you can change to using
authorsTracked
and see both authors fetched and displayed in the template.Similarly, you can switch to branch
ember-data-327
and see expected behavior while using the CP.Branch
ember-4
uses ember-data4.2.0-beta.0
and has the same unexpected behavior as3.28
Versions
Run the following command and paste the output below:
yarn list ember-source && yarn list ember-cli && yarn list --pattern ember-data
.The text was updated successfully, but these errors were encountered: