{"record":{"id":"2a8dc4cc5e734f4e","repo":"tonhowtf/omniget","slug":"omnidisc-voice-event-failed","errorCode":null,"errorMessage":"[omnidisc] voice event failed","messagePattern":"\\[omnidisc\\] voice event failed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lib/stores/omnidisc-voice-store.svelte.ts","lineNumber":487,"sourceCode":"\nasync function refreshStats() {\n  try {\n    stats = await invoke<VoiceStatsWire>(\"omnidisc_voice_stats\");\n  } catch {\n    stats = null;\n  }\n}\n\nexport async function initVoice(): Promise<void> {\n  loadVolumes();\n  if (initialized) return;\n  initialized = true;\n  try {\n    unlisten = await listen<VoiceEventPayload>(\"omnidisc://voice\", (event) => {\n      try {\n        handleEvent(event.payload);\n      } catch (e) {\n        console.warn(\"[omnidisc] voice event failed\", errorText(e));\n      }\n    });\n  } catch (e) {\n    initialized = false;\n    console.warn(\"[omnidisc] could not subscribe to voice events\", errorText(e));\n    return;\n  }\n  try {\n    unlistenDispatch = await listen<DispatchPayload>(\"omnidisc://dispatch\", (event) => {\n      try {\n        handleDispatch(event.payload);\n      } catch (e) {\n        console.warn(\"[omnidisc] call ring failed\", errorText(e));\n      }\n    });\n  } catch (e) {\n    console.warn(\"[omnidisc] could not subscribe to call rings\", errorText(e));\n  }","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src/lib/stores/omnidisc-voice-store.svelte.ts#L469-L505","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Log the raw event.payload alongside errorText(e) to identify the offending variant.","Make handleEvent defensive: validate/discriminate the payload variant before mutating state.","Regenerate the TypeScript VoiceEventPayload type from the Rust enum to fix skew.","Handle unknown-user / out-of-order events gracefully instead of throwing."],"exampleFix":"// before\nhandleEvent(event.payload);\n// after\nif (isVoiceEventPayload(event.payload)) handleEvent(event.payload);\nelse console.warn(\"unknown voice payload\", event.payload);","handlingStrategy":"type-guard","validationCode":"function isVoiceEventPayload(p: unknown): p is VoiceEventPayload {\n  return typeof p === 'object' && p !== null && 'type' in p;\n}","typeGuard":"function isVoiceEventPayload(p: unknown): p is VoiceEventPayload {\n  return (\n    typeof p === 'object' && p !== null &&\n    'type' in p && typeof (p as { type: unknown }).type === 'string'\n  );\n}","tryCatchPattern":"listen<VoiceEventPayload>(\"omnidisc://voice\", (event) => {\n  try {\n    if (!isVoiceEventPayload(event.payload)) return;\n    handleEvent(event.payload);\n  } catch (e) {\n    console.warn(\"[omnidisc] voice event failed\", errorText(e), event.payload);\n  }\n});","preventionTips":["Validate/guard the payload before running state mutations in handleEvent.","Regenerate TS event types from the Rust enum on every backend change.","Handle unknown users and out-of-order events without throwing.","Include the raw payload in warn logs to speed diagnosis."],"tags":["tauri","events","voice","payload"],"backgroundTag":"unexpected-response-shape","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"}