tonhowtf/omniget · error
[omnidisc] could not subscribe to gateway events
Error message
[omnidisc] could not subscribe to gateway events
What it means
During store init, the store subscribes to backend events (`omnidisc://dispatch`, `omnidisc://status`, `omnidisc://upload`, `omnidisc://decrypted`) via Tauri's listen(). If any listen() call rejects (event not registered, app handle unavailable) the store resets `initialized = false`, logs this warning, and aborts init — the gateway will never be connected for any instance, so all realtime features stay dead until init is retried.
Solutions
- Check errorText(e) to see which listen() call failed
- Ensure the app is running inside the Tauri webview (not a plain browser tab) and the event-emitting Rust side is initialized before the frontend subscribes
- Retry init after the runtime is ready — initialized was reset to false so a re-init is possible
- Verify frontend event names match the backend emit strings exactly
Defensive patterns
Strategy: try-catch
Validate before calling
// only init inside the Tauri runtime
if (!("__TAURI_INTERNALS__" in window)) { console.warn("not in Tauri runtime"); return; }
Try / catch
try {
offDispatch = await listen("omnidisc://dispatch", ...);
offStatus = await listen("omnidisc://status", ...);
} catch (e) {
initialized = false;
console.warn("[omnidisc] could not subscribe to gateway events", errorText(e));
return;
} Prevention
- Subscribe to events only after the Tauri runtime is ready
- Unregister old listeners before re-initializing to avoid duplicates
- Gate init on a readiness flag so a failed init can be retried once
When it happens
Trigger: Calling the store's init/connect flow when one of the four listen<T>("omnidisc://…") promises rejects — typically the Tauri runtime not ready, plugin not initialized, or running outside a Tauri window (e.g. plain browser during dev).
Common situations: Developing in a browser without the Tauri runtime so invoke/listen are stubbed or absent; app updated with renamed events while a stale backend runs; very early subscription before the app setup completes.
Related errors
- [omnidisc] could not sign out of
- [omnidisc] could not load messages
- [omnidisc] could not load older messages
- [omnidisc] dispatch handler failed
- [omnidisc] invite could not be redeemed
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/213edcbb5e38628c.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/stores/omnidisc-store.svelte.ts:1441
const offDispatch = await listen<GatewayDispatchEvent>("omnidisc://dispatch", (event) => {
const payload = event.payload;
const instance = instanceByUrl(payload.url);
if (!instance) return;
try {
handleDispatch(instance, payload.t, payload.d);
} catch (e) {
console.warn("[omnidisc] dispatch handler failed", payload.t, errorText(e));
}
});
const offStatus = await listen<GatewayStatusEvent>("omnidisc://status", (event) => handleStatus(event.payload));
const offUpload = await listen<unknown>("omnidisc://upload", (event) => handleUploadProgress(event.payload));
const offDecrypted = await listen<unknown>("omnidisc://decrypted", (event) =>
handleDecryptedEvent(event.payload),
);
unlisteners = [offDispatch, offStatus, offUpload, offDecrypted];
} catch (e) {
initialized = false;
console.warn("[omnidisc] could not subscribe to gateway events", errorText(e));
return;
}
for (const instance of instances) {
if (isDemo(instance.id)) continue;
void connectGateway(instance);
}
}
export function teardownOmnidisc() {
for (const off of unlisteners) off();
unlisteners = [];
initialized = false;
}
export async function connectGateway(instance: OmnidiscInstance): Promise<void> {
if (isDemo(instance.id)) return;
instance.status = "connecting";
instance.error = undefined;View on GitHub (pinned to 8600b91f42)