{"record":{"id":"744c3041497c4dfe","repo":"tonhowtf/omniget","slug":"omnidisc-gateway-error","errorCode":null,"errorMessage":"[omnidisc] gateway error","messagePattern":"\\[omnidisc\\] gateway error","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lib/stores/omnidisc-store.svelte.ts","lineNumber":1353,"sourceCode":"      return;\n    }\n    case \"PRESENCE_UPDATE_BULK\": {\n      for (const item of Array.isArray(d) ? d : []) {\n        const p = parsePresence(item);\n        if (p) setPresence(instance.id, p.userId, p.status);\n      }\n      return;\n    }\n    case \"USER_UPDATE\": {\n      const user = parseUser(d);\n      if (user) upsertUser(instance.id, user);\n      return;\n    }\n    case \"VOICE_STATE_UPDATE\":\n      applyVoiceState(instance.id, d);\n      return;\n    case \"GATEWAY_ERROR\":\n      console.warn(\"[omnidisc] gateway error\", instance.url, d);\n      return;\n    default:\n      return;\n  }\n}\n\nfunction mapStatus(ev: GatewayStatusEvent): { status: InstanceStatus; error?: string } {\n  switch (ev.status) {\n    case \"ready\":\n      return { status: \"connected\" };\n    case \"connecting\":\n      return { status: \"connecting\" };\n    case \"reconnecting\":\n      return { status: \"reconnecting\", error: ev.error ?? undefined };\n    case \"disconnected\":\n    default:\n      if (ev.error === ERR_UNAUTHORIZED || ev.error === ERR_NO_SESSION) return { status: \"signed_out\", error: ev.error };\n      if (ev.error) return { status: \"error\", error: ev.error };","sourceCodeStart":1335,"sourceCodeEnd":1371,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src/lib/stores/omnidisc-store.svelte.ts#L1335-L1371","documentation":"The gateway event listener receives a GATEWAY_ERROR event emitted by the Rust backend when the persistent websocket to an instance errors (connection dropped, handshake failed, protocol violation, server-sent error frame). The store logs the instance URL and payload `d` and returns — the error is informational; reconnection behavior is driven separately by handleStatus.","triggerScenarios":"Backend gateway task emits `omnidisc://dispatch` with t=\"GATEWAY_ERROR\" whenever its websocket errors: server closed the socket, DNS/TLS failure, invalid gateway URL, heartbeat timeout, or an error frame from the remote server.","commonSituations":"Instance server restart or maintenance window; laptop sleep/resume killing the socket; misconfigured instance URL (wrong port/protocol); firewall or proxy blocking long-lived websockets.","solutions":["Inspect the logged `d` payload for the underlying websocket error reason","Confirm the instance URL is correct and reachable (curl its REST endpoint)","Check whether status events show a reconnect — if not, call connectGateway again for that instance","If errors persist across reconnects, check network/firewall/proxy websocket support"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// verify reachability when configuring the instance\nconst ok = await fetch(`${url.replace(/\\/$/, \"\")}/api/health`).then(r => r.ok).catch(() => false);\n","typeGuard":null,"tryCatchPattern":"case \"GATEWAY_ERROR\":\n  console.warn(\"[omnidisc] gateway error\", instance.url, d);\n  scheduleReconnect(instance); // fallback: attempt reconnect\n  return;","preventionTips":["Validate instance URLs at add-time (scheme, host, port)","Implement reconnect with backoff on GATEWAY_ERROR","Monitor status events alongside error events to know when reconnection succeeds"],"tags":["websocket","gateway","network","tauri"],"backgroundTag":"websocket-disconnected","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}