-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix: Setting 2 full path properties fails SOFIE-2628 #34
Conversation
…ren object defined
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #34 +/- ##
==========================================
- Coverage 60.94% 60.76% -0.19%
==========================================
Files 69 69
Lines 6058 6076 +18
Branches 555 555
==========================================
Hits 3692 3692
- Misses 2355 2373 +18
Partials 11 11
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change detection logic is pretty naive and isnt factoring in that getDirectory is expecting the children property to be loaded.
I understand what the nature of the bug is now.
There's in essence 3 requests at the same time going on.
A) A getDirectory on the parent
B) A second getDirectory on the parent
C) A getDirectory on the child
C is fired directly after A is done, but at that point B isn't complete yet. The completion of B also means that the child is reinserted. This creates a change on the path of the child and resolves C even though it hasn't completed yet.
I can see this solution fixing the issue specifically for the getElementByPath case but in essence the race condition is not fundamentally fixed. Unfortunately, given how emberplus reports all its responses through updates to the tree it seems we would have to do very specific matching of how the tree is updated to whether that corresponds with the contents of the command to do a fundamental fix. (Or move the more execution synchronous model which would sadden me a bit)
Yes, I haven't attempted to fix the underlying race condition. I don't think I know enough about ember+ to be comfortable making that large of a change much here. |
Co-authored-by: Mint de Wit <araminta.hekate@gmail.com>
I agree. Another optimisation would be to implement some logic in the getElementByPath to not create these duplicate requests but this PR is fine as is by me. |
I think what is happening is:
The change detection logic is pretty naive and isnt factoring in that
getDirectory
is expecting thechildren
property to be loaded.So the first 'change' which is updating solely the
contents
is completing the request, and confusing thegetElementByPath
which is expecting the children object to have been loaded by the time that thegetDirectory
call resolves.The change here introduces a simple enum, so that the
getDirectory
request can flag as needing the children to be loaded before it can be resolved. Other calls should behave the same as before, with the previoushasResponse
being replaced with values in this enum