{"record":{"id":"a33a3033763fa2e4","repo":"tonhowtf/omniget","slug":"omnidisc-could-not-load-messages","errorCode":null,"errorMessage":"[omnidisc] could not load messages","messagePattern":"\\[omnidisc\\] could not load messages","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lib/stores/omnidisc-store.svelte.ts","lineNumber":771,"sourceCode":"  try {\n    const raw = await invoke<unknown>(\"omnidisc_list_messages\", { url: instance.url, channelId, limit: PAGE_SIZE });\n    const list = Array.isArray(raw) ? raw : [];\n    const resolve = nameResolver(instance.id);\n    const parsed = list\n      .map((m) => parseMessage(m, resolve))\n      .filter((m): m is OmnidiscMessage => m !== null);\n    hasMoreByChannel[channelId] = list.length >= PAGE_SIZE;\n    const pending = (messagesByChannel[channelId] ?? []).filter((m) => m.delivery !== \"sent\");\n    messagesByChannel = { ...messagesByChannel, [channelId]: sortMessages([...parsed, ...pending]) };\n    for (const m of parsed) {\n      bumpLastMessage(channelId, m.id);\n      if (!usersByInstance[instance.id]?.[m.authorId]) void ensureUser(instance.id, m.authorId);\n    }\n    void hydrateEncrypted(channelId);\n    void refreshGroupStatus(channelId);\n  } catch (e) {\n    loadedChannels.delete(channelId);\n    console.warn(\"[omnidisc] could not load messages\", errorText(e));\n  } finally {\n    const next = { ...loadingByChannel };\n    delete next[channelId];\n    loadingByChannel = next;\n  }\n}\n\nexport async function loadOlderMessages(channelId: string, count = PAGE_SIZE): Promise<number> {\n  const current = messagesByChannel[channelId] ?? [];\n  const instance = instanceForChannel(channelId);\n  if (instance && isDemo(instance.id)) {\n    const oldestSeq = oldestSeqByChannel[channelId];\n    if (oldestSeq === undefined || oldestSeq <= 0) return 0;\n    const endAt = (current[0]?.createdAt ?? Date.now()) - 60_000;\n    const startSeq = Math.max(0, oldestSeq - count);\n    const older = makeFixtureMessages(channelId, oldestSeq - startSeq, endAt, startSeq);\n    oldestSeqByChannel[channelId] = startSeq;\n    messagesByChannel = { ...messagesByChannel, [channelId]: [...older, ...current] };","sourceCodeStart":753,"sourceCodeEnd":789,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src/lib/stores/omnidisc-store.svelte.ts#L753-L789","documentation":"When loading a channel's message history, the store fetches messages from the instance via backend commands, and on failure clears the `loadedChannels` marker, logs this warning, and clears the per-channel loading flag in `finally`. It means the initial page of messages for `channelId` could not be retrieved — the channel appears empty/pending rather than throwing to the UI.","triggerScenarios":"Opening/joining a channel while the gateway or REST fetch behind loadMessages rejects: instance server unreachable, invalid/expired session token, channel the user lacks permission to read, malformed response from the backend command.","commonSituations":"Server temporarily down or restarted; auth token revoked; user removed from guild but channel still in local state; offline laptop reconnecting; backend command renamed or signature changed after an app update.","solutions":["Read errorText(e) to distinguish network failure from auth failure or permission denial","Verify the instance URL is reachable and the gateway is connected (check gateway status events)","Re-authenticate: sign out and back in to refresh the session token","Retry loading the channel after connectivity is restored — loadedChannels was cleared so a retry is possible"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// guard before loading\nif (loadedChannels.has(channelId) || loadingByChannel[channelId]) return;\nconst instance = instanceByUrl(url);\nif (!instance) return;\n","typeGuard":null,"tryCatchPattern":"try {\n  await invoke(\"omnidisc_load_messages\", { url, channelId });\n} catch (e) {\n  loadedChannels.delete(channelId);\n  console.warn(\"[omnidisc] could not load messages\", errorText(e));\n}","preventionTips":["Clear the loaded-channels marker on failure so a later retry can run","Check gateway status before issuing history loads","Debounce retries with backoff when the network is flaky"],"tags":["svelte","network","messages","tauri"],"backgroundTag":"network-request-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"}