tonhowtf/omniget · warning

[omnidisc] voice event failed

Error message

[omnidisc] voice event failed

What it means

The voice store's subscription to `omnidisc://voice` wraps handleEvent in try/catch; when the event payload handler throws (malformed VoiceEventPayload, unexpected event variant, bug in state reducers), this warning is logged per-event. The listener stays attached, so only the offending event is dropped.

Solutions

  1. Log the raw event.payload alongside errorText(e) to identify the offending variant.
  2. Make handleEvent defensive: validate/discriminate the payload variant before mutating state.
  3. Regenerate the TypeScript VoiceEventPayload type from the Rust enum to fix skew.
  4. Handle unknown-user / out-of-order events gracefully instead of throwing.

Example fix

// before
handleEvent(event.payload);
// after
if (isVoiceEventPayload(event.payload)) handleEvent(event.payload);
else console.warn("unknown voice payload", event.payload);
Defensive patterns

Strategy: type-guard

Validate before calling

function isVoiceEventPayload(p: unknown): p is VoiceEventPayload {
  return typeof p === 'object' && p !== null && 'type' in p;
}

Type guard

function isVoiceEventPayload(p: unknown): p is VoiceEventPayload {
  return (
    typeof p === 'object' && p !== null &&
    'type' in p && typeof (p as { type: unknown }).type === 'string'
  );
}

Try / catch

listen<VoiceEventPayload>("omnidisc://voice", (event) => {
  try {
    if (!isVoiceEventPayload(event.payload)) return;
    handleEvent(event.payload);
  } catch (e) {
    console.warn("[omnidisc] voice event failed", errorText(e), event.payload);
  }
});

Prevention

When it happens

Trigger: Backend emitting a voice event payload that does not match VoiceEventPayload (renamed/added variant, missing fields), or handleEvent throwing on an unexpected state transition (e.g. speaking update for an unknown user).

Common situations: Frontend/backend version skew after adding a new voice event variant; a peer sending malformed data that the backend forwards; state machine assumptions broken by out-of-order events.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/2a8dc4cc5e734f4e. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/stores/omnidisc-voice-store.svelte.ts:487

async function refreshStats() {
  try {
    stats = await invoke<VoiceStatsWire>("omnidisc_voice_stats");
  } catch {
    stats = null;
  }
}

export async function initVoice(): Promise<void> {
  loadVolumes();
  if (initialized) return;
  initialized = true;
  try {
    unlisten = await listen<VoiceEventPayload>("omnidisc://voice", (event) => {
      try {
        handleEvent(event.payload);
      } catch (e) {
        console.warn("[omnidisc] voice event failed", errorText(e));
      }
    });
  } catch (e) {
    initialized = false;
    console.warn("[omnidisc] could not subscribe to voice events", errorText(e));
    return;
  }
  try {
    unlistenDispatch = await listen<DispatchPayload>("omnidisc://dispatch", (event) => {
      try {
        handleDispatch(event.payload);
      } catch (e) {
        console.warn("[omnidisc] call ring failed", errorText(e));
      }
    });
  } catch (e) {
    console.warn("[omnidisc] could not subscribe to call rings", errorText(e));
  }

View on GitHub (pinned to 8600b91f42)