Prevents silent WebSocket disconnections via Web Worker heartbeats and reconnection strategies.
90
90%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Prevents silent WebSocket disconnections via Web Worker heartbeats and reconnection strategies.
Browser tabs that go into the background throttle JavaScript timers, causing the Supabase Realtime WebSocket to miss heartbeats and silently disconnect. The application continues rendering stale data with no error indication. This tile enforces three defenses: Web Worker-based connections that bypass timer throttling, active heartbeat monitoring with automatic reconnection, and channel count limits to prevent proliferation.
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
realtime: { worker: true },
});The worker: true flag moves the WebSocket connection into a Web Worker, bypassing the browser's background tab timer throttling.
let lastHeartbeat = Date.now();
const HEARTBEAT_INTERVAL = 30_000;
setInterval(() => {
if (Date.now() - lastHeartbeat > HEARTBEAT_INTERVAL * 2) {
supabase.realtime.disconnect();
supabase.realtime.connect();
}
}, HEARTBEAT_INTERVAL);1s -> 2s -> 4s -> 8s -> 16s -> 30s (cap)
supabase-mcp-verification — validates project configuration.realtime-channel-authorization — provides the secured channels that this tile makes resilient.Runs after realtime-channel-authorization secures the channels. This is the final tile in the Realtime stack — it adds client-side stability to already-secured channels. No downstream tiles depend on this tile.