You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: