{"record":{"id":"d2a5676e0f9d40a1","repo":"tonhowtf/omniget","slug":"omnidisc-could-not-subscribe-to-voice-events","errorCode":null,"errorMessage":"[omnidisc] could not subscribe to voice events","messagePattern":"\\[omnidisc\\] could not subscribe to voice events","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/stores/omnidisc-voice-store.svelte.ts","lineNumber":492,"sourceCode":"    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  }\n  try {\n    applyStatus(await invoke<VoiceStatusWire>(\"omnidisc_voice_status\"));\n  } catch {\n    return;\n  }","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src/lib/stores/omnidisc-voice-store.svelte.ts#L474-L510","documentation":"The voice store's init awaits listen(\"omnidisc://voice\"); if that subscription call itself rejects, `initialized` is reset to false, this warning is logged, and init aborts early — the dispatch-channel subscription and initial status fetch never run. Voice features are effectively unavailable for the session.","triggerScenarios":"Calling the voice init while the Tauri event/IPC layer is unavailable (non-Tauri runtime, premature call before webview ready), or a backend that never registers the `omnidisc://voice` event channel.","commonSituations":"Tests or Storybook rendering components that init the store outside a Tauri window; init called twice with a race resetting `initialized`; app started before the Rust setup hook registered events.","solutions":["Only run the voice store init inside a real Tauri runtime; gate with an isTauri check.","Retry the subscription with backoff, or surface a disabled-voice UI state when initialized stays false.","Ensure the Rust setup registers/emits the `omnidisc://voice` topic before the frontend boots.","Make init idempotent to avoid a second init racing and resetting initialized."],"exampleFix":"// before\nawait initVoice();\n// after\nif (!isTauri()) return;\nawait initVoice();\nif (!initialized) showVoiceUnavailable();","handlingStrategy":"retry","validationCode":"if (!('__TAURI_INTERNALS__' in window)) { markVoiceUnavailable(); return; }","typeGuard":"export function isTauri(): boolean {\n  return typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window;\n}","tryCatchPattern":"try {\n  unlisten = await listen<VoiceEventPayload>(\"omnidisc://voice\", onVoiceEvent);\n} catch (e) {\n  initialized = false;\n  console.warn(\"[omnidisc] could not subscribe to voice events\", errorText(e));\n  await retryWithBackoff(subscribeVoice, { attempts: 3 });\n  return;\n}","preventionTips":["Gate voice init on the Tauri runtime and on backend readiness.","Retry the subscription with exponential backoff before giving up.","Show an explicit voice-unavailable UI state when initialized stays false.","Keep init single-flight; never let a concurrent call reset initialized."],"tags":["tauri","events","voice","subscription"],"backgroundTag":"event-subscribe-failed","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"}