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
Calling sync on a contract is difficult to do correctly for a few reasons:
It doesn't affect or take into account reference counts
It's a one-off operation and it might fail
When the app starts, we also call sync to bootstrap it, but as documented in #2653, this leads to issues that interfere with saving data for notifications, implementing an offline PWA and implementing user-local snapshots, and potentially with other things.
Issues with WebSocket subscriptions
Subscribing to a channel gives the server information about the channel (contract) ID only. This means that a subscription will only receive events for future events, not for past events. In itself this isn't an issue, but it means that sometimes sync must be used (to receive past events).
Solution
We already, for the most part, receive events over the WebSocket, but need to use sync in certain situations, such as when our contract has fallen behind. In these situations, sync must be called, but, as mentioned, this can be challenging to do correctly and flexibly.
Instead, we can change the current way of subscribing to a contract so that we can also specify a height. If given, the height will act as a 'from' point, and the WS will behave similarly to using sync. This is advantageous because we already have logic in place to handle various error conditions and situations that arise in the WS, and this approach could allow the bootstrapping process to behave as if the app had never been closed.
The text was updated successfully, but these errors were encountered:
Problem
Issues with
sync
Calling
sync
on a contract is difficult to do correctly for a few reasons:When the app starts, we also call sync to bootstrap it, but as documented in #2653, this leads to issues that interfere with saving data for notifications, implementing an offline PWA and implementing user-local snapshots, and potentially with other things.
Issues with WebSocket subscriptions
Subscribing to a channel gives the server information about the channel (contract) ID only. This means that a subscription will only receive events for future events, not for past events. In itself this isn't an issue, but it means that sometimes
sync
must be used (to receive past events).Solution
We already, for the most part, receive events over the WebSocket, but need to use sync in certain situations, such as when our contract has fallen behind. In these situations,
sync
must be called, but, as mentioned, this can be challenging to do correctly and flexibly.Instead, we can change the current way of subscribing to a contract so that we can also specify a height. If given, the height will act as a 'from' point, and the WS will behave similarly to using
sync
. This is advantageous because we already have logic in place to handle various error conditions and situations that arise in the WS, and this approach could allow the bootstrapping process to behave as if the app had never been closed.The text was updated successfully, but these errors were encountered: