Skip to content

Commit 0d2b259

Browse files
committed
fix: use current value instead of return value
1 parent be0a26a commit 0d2b259

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,10 +859,13 @@ export class YSocketIO {
859859
assert(this.client)
860860
const redis = this.client.redis
861861
const key = this.getLeaderKeyOf(namespace)
862-
const ok = await redis.set(key, this.serverId, {
862+
await redis.set(key, this.serverId, {
863863
NX: true,
864864
PX: PERSIST_LEADER_HEARTBEAT_INTERVAL
865865
})
866+
867+
const curLeader = await redis.get(key)
868+
const ok = curLeader === this.serverId
866869
if (!ok) return false
867870

868871
this.persistentLeaderOf.add(namespace)

0 commit comments

Comments
 (0)