From c2226a700d4d9dd3423d54165ea24ac5a7b20c76 Mon Sep 17 00:00:00 2001 From: Charlie Hsieh Date: Mon, 14 Oct 2024 20:34:50 +0800 Subject: [PATCH] fix: init listeners before getDoc to solve server miss sync request problem --- src/y-socket-io/y-socket-io.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/y-socket-io/y-socket-io.js b/src/y-socket-io/y-socket-io.js index 58086ca..2993fd0 100644 --- a/src/y-socket-io/y-socket-io.js +++ b/src/y-socket-io/y-socket-io.js @@ -153,6 +153,10 @@ export class YSocketIO { this.namespaceStreamMap.set(namespace, stream) this.streamNamespaceMap.set(stream, namespace) + this.initSyncListeners(socket) + this.initAwarenessListeners(socket) + this.initSocketListeners(socket) + const doc = await this.client.getDoc(namespace, 'index') if ( @@ -162,12 +166,6 @@ export class YSocketIO { // need to renew subscription id and make sure that we catch the latest content. this.subscriber.ensureSubId(stream, doc.redisLastId) } - - this.initSyncListeners(socket) - this.initAwarenessListeners(socket) - - this.initSocketListeners(socket) - this.startSynchronization(socket, doc) })