Skip to content

Commit 19a5abd

Browse files
committed
fix(realtime): gate isReady() on loaded script SHAs, not just connection
Follow-up to the prior isConnected change, which was incomplete: the redis client's 'ready' event flips isConnected=true on connect — before initialize() loads the Lua scripts — so a bare isConnected check reports ready while removeUserFromRoom / updateUserActivity would silently no-op on a null SHA. Gate isReady() on the SHAs too, so the POST endpoints return a retryable 503 during that startup window instead of proceeding against unloaded scripts. Standard readiness-probe discipline.
1 parent 8ae486a commit 19a5abd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

apps/realtime/src/rooms/redis-manager.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,14 @@ export class RedisRoomManager implements IRoomManager {
160160
}
161161

162162
isReady(): boolean {
163-
return this.isConnected
163+
// Gate on the loaded script SHAs, not just the connection: the `ready` event flips
164+
// `isConnected` true as soon as the socket connects — before `initialize()` loads the Lua
165+
// scripts — so a bare `isConnected` check would report ready while `removeUserFromRoom` /
166+
// `updateUserActivity` would silently no-op on a null SHA. Reporting not-ready here makes the
167+
// POST endpoints return a retryable 503 during that startup window instead.
168+
return (
169+
this.isConnected && this.removeRoomScriptSha !== null && this.updateActivityScriptSha !== null
170+
)
164171
}
165172

166173
async initialize(): Promise<void> {

0 commit comments

Comments
 (0)