FIG_006 [ SOCKET ]
FIG_006 // Interactive Cutaway durability/socket

DurabilitySocket

Hibernatable WebSocket RPC with validated inbound allowlists and bounded replayable outbound events.

FIG_006 [ DURABILITY_SOCKET ] HIBERNATE // 0 ALARMS
1 Edge WS / Allowlist 2 SQLite Event + Trim 3 Replay / Resync
1 / 5
WARM (SEQ #46): Hibernate the DO to watch the 3 vacuum tubes power dark while the Edge Relay auto-replies PING ↔ PONG, or click Client A to test an allowed list() RPC.
LINKED CLI A LIVE ✓ SEQ #46 UPDATES meta: user-a subs: ["updates"] CONNECTED • CLICK RPC CLI B LIVE ✓ SEQ #46 UPDATES meta: user-b cursor: #46 (sync) STREAMING LIVE EDGE STANDBY RELAY ctx.acceptWebSocket WS ATTACH • A meta: user-a ch:room • subs:[u] AUTO-PONG COIL PING ↔ PONG 0 DO WAKEUPS WS OPEN • 0 RAM WS ATTACH • B meta: user-b ch:room • subs:[u] 2 WS ATTACHED KEPT ACROSS SLEEP ATTACH SERIALIZED V1 • RPC V2 • RAM V3 • TX DO AWAKE • WARM 0 DO ALARMS ★ ALLOWLIST BAND-PASS READY RPC: list() ALLOWLIST MATCH ✓ inbound: { list, send } 0 SQLITE WRITES NOT PERSISTED (USE DURABILITY FOR MUTATIONS) REPLAY BUFFER (MAX 5) WIN #42..#46 #43 ✂ TRIM #41 #42 OLD #43 ROW #44 ROW #45 ROW #46 HEAD durability_socket_events SEQ NEVER RESETS NEWEST ROW KEPT • READY FOR REPLAY CLIENT A SUB: UPDATES EDGE RELAY 0-WAKE AUTO-PONG CLIENT B REPLAY / RESYNC WS ATTACH META + CHANNEL VACUUM TUBES DO RAM • SLEEPS 0 DO ALARMS HIBERNATION API ALLOWLIST GATE NOT PERSISTED REPLAY BUFFER MAX 5 + TRIM ✂ SEQ MONOTONIC TRIMMED → RESYNC
GUARANTEE: HIBERNATED WS (0 ALARMS) • BOUNDED SQLITE REPLAY (NEWEST KEPT)
SPEC // 06 [ ARCHITECTURE ]
01 // What it’s for

Why reach for DurabilitySocket

Use DurabilitySocket to wire browser or edge clients straight into a Durable Object over Cloudflare Hibernatable WebSockets—exposing an explicit schema-validated inbound RPC surface while broadcasting sequenced outbound events that reconnecting clients can replay cleanly.


02 // How it works

Inside your Durable Object

  1. 01Zero-wakeup hibernation standby: Connection metadata, channel, and subscriptions are serialized onto each WebSocket attachment via ctx.acceptWebSocket; the runtime answers heartbeats without waking an idle DO.
  2. 02Strict inbound allowlist: Every client RPC must match a declared inbound handler and pass schema validation before touching object state; unknown methods are rejected at the band-pass filter.
  3. 03Bounded replay buffer: Outbound events persist in durability_socket_events with monotonic sequence numbers so briefly disconnected clients catch up seamlessly.
  4. 04Explicit resync signal: When older events are trimmed past a reconnecting client's cursor, the socket signals a clean RESYNC instead of silently dropping gaps.
Storage
durability_socket_events
Hibernation
0 DO wakeups on ping/pong
Import
durability/socket