Skip to content

Commit 409d6fc

Browse files
authored
Merge pull request #9 from hackmdio/fix-sync-timing
fix: init listeners before getDoc to solve server miss sync request problem
2 parents 64baa5d + c2226a7 commit 409d6fc

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ export class YSocketIO {
153153
this.namespaceStreamMap.set(namespace, stream)
154154
this.streamNamespaceMap.set(stream, namespace)
155155

156+
this.initSyncListeners(socket)
157+
this.initAwarenessListeners(socket)
158+
this.initSocketListeners(socket)
159+
156160
const doc = await this.client.getDoc(namespace, 'index')
157161

158162
if (
@@ -162,12 +166,6 @@ export class YSocketIO {
162166
// need to renew subscription id and make sure that we catch the latest content.
163167
this.subscriber.ensureSubId(stream, doc.redisLastId)
164168
}
165-
166-
this.initSyncListeners(socket)
167-
this.initAwarenessListeners(socket)
168-
169-
this.initSocketListeners(socket)
170-
171169
this.startSynchronization(socket, doc)
172170
})
173171

0 commit comments

Comments
 (0)