-
Notifications
You must be signed in to change notification settings - Fork 49
Fix connect()
resolving early with Rust client
#643
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
Conversation
🦋 Changeset detectedLatest commit: 5c57ea8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/common/src/client/sync/stream/AbstractStreamingSyncImplementation.ts
Outdated
Show resolved
Hide resolved
I did some testing to see the exact status sequence during the initial connection attempt on the various versions. For these tests, I added an artificial delay of 1500ms before sending the first checkpoint message on the service (after connecting). The first number in the logs here indicate time since calling main branch, JS implementation:
Comments:
main branch, RUST implementation:
Comments:
this branch, RUST implementation:
Comments:
Overall comments
However, I think we should improve the status reporting further:
|
At least in the node test (
Fixed for Rust now.
I don't agree with this one in combination with the one above. How are we downloading rows before the first
Fixed! |
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.
From my side this looks good to me.
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.
I don't agree with this one in combination with the one above. How are we downloading rows before the first checkpoint line? The Rust client sets downloading: true from the checkpoint until a checkpoint_complete message which sounds like the correct behavior to me. Which behavior would you expect, downloading: true initially until the first checkpoint is completed and then again for subsequent ones?
For this one, the general issue is that if you get {connecting: false, connected: true, downloading: false}
, there is no nice way to know if it is "we are expecting a checkpoint soon which may contain data to download" (which is the case on initial connection) versus "connection is idle" (already received a checkpoint). This could potentially be solved by adding another status field. But either way this is not a regression, so happy to revisit later.
dcc1491
to
c635c9f
Compare
With the JavaScript sync client, the promise returned by
connect()
is supposed to return after a connection has been established and the first sync line received (this is different to all our other SDKs, which return as soon as a connection task has been set up and started).The way this behavior is implemented is that
connect()
registers astatusUpdated
handler that completes once theconnected
status is changed. This works with the JavaScript client because it only changes fields that actually need to change. With Rust however, we receive a fullSyncStatus
snapshot instead (so we callupdateSyncStatus
with a complete status that will always haveconnected
set - even tofalse
initially).The workaround feels a bit hacky, but since something like
statusUpdated
doesn't really work with the Rust client at all, the best approach I could come up with is to excludeconnected
from the options passed toupdateSyncStatus
in the initial connection setup status.This fixes a bug reported on Discord. However, I could not report longer connection times with the new Rust client after adding the
connect()
call with the fix.