Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/y-socket-io/y-socket-io.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,13 @@ export class YSocketIO {
assert(this.client)
const redis = this.client.redis
const key = this.getLeaderKeyOf(namespace)
const ok = await redis.set(key, this.serverId, {
await redis.set(key, this.serverId, {
NX: true,
PX: PERSIST_LEADER_HEARTBEAT_INTERVAL
})

const curLeader = await redis.get(key)
const ok = curLeader === this.serverId
if (!ok) return false

this.persistentLeaderOf.add(namespace)
Expand Down