-
-
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
Additional test coverage for async belongsTo mutation #5584
Conversation
Unfortunately, this test does not test the issue reported in #5575. We don't expect the proxy instance to have changed, only the value proxied. The proxy instance should be stable. I produced a test ensuring that the value does indeed update, and we can see that it does (commit pushed). |
6ee1ac8
to
38a1f01
Compare
I believe your test works with sync belongsTo, while my problem was with async. But I don't know if this makes any difference. |
@jlami you can see here that I am working with an async belongsTo: https://github.com/emberjs/data/pull/5584/files#diff-6c89bc797aa543dc33556580b5705bedR22 Your test was assuming that the instance of the |
ok, but your asserts are on the other side of the relationship, which is sync
Yes, I'm assuming that the problem in #5575 is that the belongsTo should change value. But I think that might be better discussed over there. |
they are on both sides of the relationship
the
The bug that I think the above is causing is that we notify both for the removal and for the addition and then again once we've settled state. This is a known issue we've had for multiple major versions that I've been hoping to refactor and fix. TL;DR since observers are sync, notifying causes them to trigger instantly. Since state is not settled, they get broken/partial/wrong state when they trigger the call to What we should do is move to a queue system where we only notify the UI a single time, and only do so once we've settled the state of the relationship. |
Ah, yes, I missed the await part.
I do agree that the observers do have some problems now with ED and it would be good to improve that. But I still think the bug I'm talking about is not related. I have changed the twiddle to show more clearly what I think is the cause. The https://ember-twiddle.com/8699e6c887c9eb2cb4344fb1d2551dbe?openFiles=controllers.application.js%2C I have changed the application controller to simulate what ED is doing with the proxy as far as I understand. This illustrates the problems that arise from keeping a reference constant, while using |
@runspired This new constant reference behavior seems to me like a breaking change that could only be done in a ember-data v4.0.0 change. Until then perhaps keep the old behavior or update to ember-data v4.0.0 now. |
@broerse it was constant in most situations before too, but more than that, it would defeat the purpose of being a proxy to rely on it being unstable. There may be a bug in ember-data where we don't notify properly, and given a test showing this behavior I'm happy to poke more at it. However, given the example above, I suspect that one or more of the following statements regarding ember-power-select and this issue is true:
I'll leave it to folks like @krisselden and @rwjblue to weigh in on those first three; however, as regards the last I'm inclined to think we have no issue given that the rendering tests I added in this PR pass. Power Select Issue for reference: cibernox/ember-power-select#1147 |
@runspired @krisselden @rwjblue I don't think this change is necessary wrong but it is breaking and probably Ember/Glimmer needs to be changed too. It is not only power select but all component that check |
* Added failing test for emberjs#5575 * add integration and acceptance tests for editing an async belongsTo
Test for #5575