CtrlK
BlogDocsLog inGet started
Tessl Logo

g14wxz/realtime-connection-resilience

Prevents silent WebSocket disconnections via Web Worker heartbeats and reconnection strategies.

90

Quality

90%

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

realtime-resilience-rules.mdrules/

Realtime Resilience Rules

FATAL Constraints

  • Missing worker: true in browser environments is FATAL. Agents MUST instantiate the Supabase client with realtime: { worker: true }. Without this flag, browser tab backgrounding throttles the WebSocket and causes silent disconnections that are unrecoverable without a full page reload.
  • Unbounded channel proliferation is FATAL. Active channel count MUST be monitored. Agents MUST HALT new subscriptions if active channels exceed 100. Exceeding this limit indicates a subscription leak.
  • Missing heartbeat monitoring is FATAL. Agents MUST implement heartbeat tracking. A connection without heartbeat monitoring silently dies and the application receives no indication of data loss.

Mandatory Behaviors

  • MUST set worker: true on every Supabase client used in a browser environment.
  • MUST implement heartbeat monitoring with a 30-second default interval (configurable).
  • MUST trigger reconnection if no message is received within 2x the heartbeat interval.
  • MUST implement exponential backoff for reconnection attempts: 1s, 2s, 4s, 8s, capped at 30s.
  • MUST re-subscribe to all previously active channels after reconnection completes.
  • MUST NOT create duplicate channel subscriptions during the reconnection flow.
  • MUST log a warning when active channel count exceeds 10.
  • MUST NOT set worker: true in non-browser environments (Node.js, Deno Edge Functions) where Web Workers are unavailable.

tile.json