Skip to content

Commit

Permalink
feat: delay client sync step until server is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
galaxian85 committed Jan 17, 2025
1 parent eb99a03 commit 847c7e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/y-socket-io/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class SocketIOProvider extends Observable {

this.doc.on('update', this.onUpdateDoc)

this.socket.on('connect', () => this.onSocketConnection(resyncInterval))
this.socket.once('ready-for-sync', () => this.onSocketConnection(resyncInterval))

this.socket.on('disconnect', (event) => this.onSocketDisconnection(event))

Expand Down
1 change: 1 addition & 0 deletions src/y-socket-io/y-socket-io.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export class YSocketIO {
this.client.getDoc(namespace, 'index').then((doc) => {
assert(socket.user)
assert(this.subscriber)
socket.emit('ready-for-sync')
if (
api.isSmallerRedisId(doc.redisLastId, socket.user.initialRedisSubId)
) {
Expand Down

0 comments on commit 847c7e6

Please sign in to comment.