diff --git a/src/realtime.ts b/src/realtime.ts index 9e9022e..6f79759 100644 --- a/src/realtime.ts +++ b/src/realtime.ts @@ -110,6 +110,16 @@ export function createArcadiaRealtime(opts: ArcadiaRealtimeOptions): ArcadiaReal setStatus("connecting"); const token = await opts.getToken(); + // No session → don't open the socket. Phoenix would refuse the + // handshake on the server (TenantSocket.connect/3 requires a JWT) + // and the client would retry forever, spamming both ends. Callers + // should invoke connect() again after login (e.g. on + // `crema:session-change`). + if (!token) { + setStatus("idle"); + return; + } + const factory = opts.socketFactory ?? ((endpoint, o) => new Socket(endpoint, o));