We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be0a26a commit 0d2b259Copy full SHA for 0d2b259
src/y-socket-io/y-socket-io.js
@@ -859,10 +859,13 @@ export class YSocketIO {
859
assert(this.client)
860
const redis = this.client.redis
861
const key = this.getLeaderKeyOf(namespace)
862
- const ok = await redis.set(key, this.serverId, {
+ await redis.set(key, this.serverId, {
863
NX: true,
864
PX: PERSIST_LEADER_HEARTBEAT_INTERVAL
865
})
866
+
867
+ const curLeader = await redis.get(key)
868
+ const ok = curLeader === this.serverId
869
if (!ok) return false
870
871
this.persistentLeaderOf.add(namespace)
0 commit comments