-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
belongsTo relationship causes "used previously in the same computation" error #19003
Comments
I think this is a really interesting conversation, especially as we all rely more and more on autotracking inter-opting with things that implement Observables. My initial feeling was that b/c we are mixing paradigms of an array that implements @pzuraq Is this true that some solutions might not work with autotracking and have to be re-thought in app code or do we have preferred mechanism of fixing the source as detailed towards the bottom of this comment without a full re-write towards autotracking semantics? Perhaps a more general question as well is - are Observable friendly Array-like behaviours necessarily at odds with autotracking or is it a case by case basis like this one? |
@wongpeiyi I'm working on a reproducible test for this issue. The core of the problem seems to be some side effects ( |
@snewcomer thank you! I don't quite know enough about the internals but I suspect it has more to do with InternalModel + PromiseProxy than ArrayProxy. The array and Rgd InternalModel: the stack trace pointed to https://github.com/emberjs/data/blob/e154539507199a85481f0621e99fb4d2b2efffcb/packages/store/addon/-private/system/model/internal-model.ts#L828 I'm just guessing here, but it seems like I'm consuming a belongs-to This is conjecture, so let me see if I can create more test cases, e.g. without requiring arrays |
This commit might be closer to what we are looking for. Lastly, need to trigger glimmer tracking/untrack. I'll see what other steps we might need to take to get this to fail... |
I've updated the investigation in the original ticket here: emberjs/data#7196 (comment) TL;DR user error + mirage funkiness results in this. There's probably some things the framework team should consider for improving these cases though. One of which is an issue in glimmer-vm in the DEBUG environment wherein having an unstable getter accessed multiple times by a template is problematic only in DEBUG and not in production where PropertyReferences are merged. See glimmerjs/glimmer-vm#1111 for more details. See the linked issue in EmberData for a complete run down. |
Thanks a lot for the explanation! It was really useful. Finally got a test reproduction working as well (albeit integration)! Initially reproduced with a list of EmberData like models like the reproduction in this issue. However, pruned the test case to show the simplest path to hitting the error - https://github.com/emberjs/ember.js/pull/19009/files |
First posted in emberjs/data#7196 but was referred here
When an API payload is received with an association not already set on a Ember Data model, the following error is seen:
This happens when the model is being consumed in a component template (via a getter) that depends on
post.user
Reproduction
https://github.com/wongpeiyi/data-computation
Description
filterBy('user.id')
, the error is thrownThe error is not thrown when:
{{@data.length}}
in the template instead of the component getterThis seems like a use case that should "just work"
Versions
The text was updated successfully, but these errors were encountered: