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

Docs not being synced despite salted handshake success #240

Closed
basham opened this issue Mar 13, 2022 · 5 comments · Fixed by #279
Closed

Docs not being synced despite salted handshake success #240

basham opened this issue Mar 13, 2022 · 5 comments · Fixed by #279
Milestone

Comments

@basham
Copy link

basham commented Mar 13, 2022

The WebsocketPeerScenario includes a test that syncs two TransportWebsocketServer instances. Please also add a scenario in which a TransportWebsocketClient syncs with a TransportWebsocketServer.

Background

I'm trying to get a local project to work. Maybe adding this test will reveal a bug that can be fixed or reveal something that I need to change on my end. If there still isn't a fix for my situation in doing this work, at least there is more test coverage.

More specifically, I have a deno script that inserted data in a Sqlite replica (earthstar@8.2.4). This was synced to a local instance of the replica server (v1.1.1). The Sqlite databases are identical, so the sync worked. Now, I have a local browser environment (with earthstar-bundle@8.2.4) in which I'm trying to sync that server data to the browser. After the salted handshake, the messages returned from the server generally cycle in sequence among these three messages:

  1. REQUEST: serveShareQuery
  2. REQUEST: serveAllShareStates
  3. RESPONSE (data.docs is always empty)

The server and client are recognizing common shares. It just seems like the server is not sending documents to the client.

@sgwilym
Copy link
Contributor

sgwilym commented Mar 14, 2022

Could you give replica-server 1.1.2 a go? Having serveShareQuery asked for repeatedly makes me think that one end of that conversation doesn't have my recent fixes, as it should now only be asked for at the beginning of a sync or when a replica is added or removed.

v8.2.4 contains fixes for ReplicaDriverLocalStorage + IndexedDB which fixed an issue like the one you're describing (peers see each others shares but don't exchange docs). Is there a chance your browser app could be using a cached version of Earthstar?

The two websocket servers you see in those scenarios are actually two servers a single websocket client in the test syncs with concurrently, so websockets are being tested from all ends!

@sgwilym sgwilym changed the title Add missing test for Websocket client Docs not being synced despite salted handshake success Mar 14, 2022
@basham
Copy link
Author

basham commented Mar 14, 2022

I'm now using replica-server@1.1.2.

As for my browser version of Earthstar, I compiled my own bundle of v8.2.4 (rather than copying it over from the CDN), and I'm including it via npm. Within node_modules, I've edited that bundle to use console.log() to output the Websocket messages. That's the only tweak I've done. Because I'm seeing those custom logs, I'm confident I'm using the latest version of Earthstar. If a cached version was being used, I wouldn't see the logs. And just to be extra sure, I inspected a diff between my custom bundle version and what is posted on the Earthstar CDN. The only differences are mostly about different minified variable names. There is no logic differences, as you would expect if you were comparing different versions of the same code. For reference, I'm using deno@1.19.1 on macOS.

Thanks for clarifying about the Websocket test.

With the change to replica-server, I am noticing a change in the messages the browser receives, but the documents are still not being sent. After the salted handshake (serveSaltedHandshake), there is only one serveAllShareStates request, rather than a continuous stream of them like before. However, the browser continues to receive message requests for serveShareQuery and response messages with empty docs. These two messages repeat continuously.

@basham
Copy link
Author

basham commented Mar 14, 2022

As additional tests in the browser, I swapped out ReplicaDriverIndexedDB for ReplicaDriverMemory and ReplicaDriverLocalStorage. In all cases, the Websocket messages are identical (as I described in my last comment).

@sgwilym
Copy link
Contributor

sgwilym commented Mar 15, 2022

Could you post a full set of logs for me in a gist? One reason two peers may not return docs to one another is because they believe they've caught up with each other. I'd like to see which localIndex each side is requesting from each other.

@basham
Copy link
Author

basham commented Mar 16, 2022

This gist contains 5 to 10 seconds of the Websocket messages that the browser received from replica-server. I've logged the messages as JSON.
https://gist.github.com/basham/13af3ec5f6395b988ecaf1c924120cd1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants