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 0d2b259 commit cdc04edCopy full SHA for cdc04ed
src/y-socket-io/y-socket-io.js
@@ -859,13 +859,13 @@ export class YSocketIO {
859
assert(this.client)
860
const redis = this.client.redis
861
const key = this.getLeaderKeyOf(namespace)
862
- await redis.set(key, this.serverId, {
+ const prevVal = await redis.set(key, this.serverId, {
863
NX: true,
864
- PX: PERSIST_LEADER_HEARTBEAT_INTERVAL
+ PX: PERSIST_LEADER_HEARTBEAT_INTERVAL,
865
+ GET: true
866
})
867
- const curLeader = await redis.get(key)
868
- const ok = curLeader === this.serverId
+ const ok = prevVal === this.serverId || prevVal === null
869
if (!ok) return false
870
871
this.persistentLeaderOf.add(namespace)
0 commit comments