Skip to content

Commit 847c7e6

Browse files
committed
feat: delay client sync step until server is ready
1 parent eb99a03 commit 847c7e6

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/y-socket-io/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class SocketIOProvider extends Observable {
157157

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

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

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

src/y-socket-io/y-socket-io.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export class YSocketIO {
171171
this.client.getDoc(namespace, 'index').then((doc) => {
172172
assert(socket.user)
173173
assert(this.subscriber)
174+
socket.emit('ready-for-sync')
174175
if (
175176
api.isSmallerRedisId(doc.redisLastId, socket.user.initialRedisSubId)
176177
) {

0 commit comments

Comments
 (0)