Skip to content
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

scopes can get out of sync #375

Closed
catmando opened this issue Mar 11, 2021 · 0 comments
Closed

scopes can get out of sync #375

catmando opened this issue Mar 11, 2021 · 0 comments
Labels
bug Something isn't working ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch

Comments

@catmando
Copy link
Contributor

if data is fetched at the same time as a new record is created.

For example
on_client { SomeModel.first.other_models.count } # <- causes a fetch, while we are fetching we do:
OtherModels.create(some_model: SomeModel.first) # <- if timing is just right...
expect { SomeModel.first.other_models.count }.to_on_client eq(2) # <- returns 3!

Why? if the timing is just right, the new model will get created while the fetch is being calculated, but if the after commit hook is delayed, and finishes, AFTER the fetch returns, then we end up adding the new model on, even though the fetch found it was there.

The solution will be to include the time that the model is created/updated/destroyed in the data packet to the client, and to compare this with the time stamp that the scope was last updated by a fetch. If the fetch was sent AFTER the time stamp of the broadcast, then the scope is invalidated, and will be refetched.

@catmando catmando added the bug Something isn't working label Mar 11, 2021
@catmando catmando added this to the alpha1.5 milestone Mar 11, 2021
@catmando catmando removed this from the alpha1.5 milestone Mar 11, 2021
@catmando catmando added the ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch label Mar 15, 2021
@catmando catmando reopened this Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch
Projects
None yet
Development

No branches or pull requests

1 participant