{"record":{"id":"d547334d81f3f59c","repo":"tonhowtf/omniget","slug":"omnidisc-could-not-load-older-messages","errorCode":null,"errorMessage":"[omnidisc] could not load older messages","messagePattern":"\\[omnidisc\\] could not load older messages","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lib/stores/omnidisc-store.svelte.ts","lineNumber":819,"sourceCode":"      limit: count,\n    });\n    const list = Array.isArray(raw) ? raw : [];\n    const resolve = nameResolver(instance.id);\n    const parsed = list.map((m) => parseMessage(m, resolve)).filter((m): m is OmnidiscMessage => m !== null);\n    hasMoreByChannel[channelId] = list.length >= count;\n    const known = new Set((messagesByChannel[channelId] ?? []).map((m) => m.id));\n    const fresh = parsed.filter((m) => !known.has(m.id));\n    messagesByChannel = {\n      ...messagesByChannel,\n      [channelId]: sortMessages([...fresh, ...(messagesByChannel[channelId] ?? [])]),\n    };\n    for (const m of fresh) {\n      if (!usersByInstance[instance.id]?.[m.authorId]) void ensureUser(instance.id, m.authorId);\n    }\n    void hydrateEncrypted(channelId);\n    return fresh.length;\n  } catch (e) {\n    console.warn(\"[omnidisc] could not load older messages\", errorText(e));\n    return 0;\n  } finally {\n    const next = { ...loadingByChannel };\n    delete next[channelId];\n    loadingByChannel = next;\n  }\n}\n\nexport function hasUploadsInFlight(channelId: string): boolean {\n  return (uploadsByChannel[channelId] ?? []).some((u) => u.state !== \"done\" && u.state !== \"failed\");\n}\n\nexport async function sendMessage(channelId: string, content: string, replyTo?: string): Promise<void> {\n  const instance = instanceForChannel(channelId);\n  const text = content.trim();\n  const ready = (uploadsByChannel[channelId] ?? []).filter((u) => u.state === \"done\");\n  if (!text && ready.length === 0) return;\n  if (hasUploadsInFlight(channelId)) return;","sourceCodeStart":801,"sourceCodeEnd":837,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src/lib/stores/omnidisc-store.svelte.ts#L801-L837","documentation":"This is the pagination (load older) path: when the user scrolls up, the store fetches an earlier page of messages for `channelId`; on any rejection it logs this warning and returns 0, signaling to the scroll handler that no older messages were fetched (which typically stops further pagination attempts).","triggerScenarios":"Scrolling to the top of a channel triggers the older-messages backend invoke and it rejects: transient network drop, session expired mid-session, rate limiting on the instance API, or the backend returning an unexpected shape that a parse step rejects.","commonSituations":"Long-running sessions whose token expired; rate-limited instance servers after aggressive scrolling; mobile/flaky connections; servers that pruned history so the before-cursor is invalid.","solutions":["Check errorText(e) for rate-limit or auth-specific messages and retry after backoff if rate-limited","Re-authenticate if the error indicates an expired/invalid token","Verify gateway connectivity before retrying pagination","Surface a 'retry' affordance in the UI since the function returns 0 and silently stops pagination"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// only paginate when connected and not already loading\nif (loadingByChannel[channelId] || !oldestMessageId) return 0;\n","typeGuard":null,"tryCatchPattern":"try {\n  const n = await invoke<number>(\"omnidisc_load_older\", { url, channelId, before });\n  return n;\n} catch (e) {\n  console.warn(\"[omnidisc] could not load older messages\", errorText(e));\n  return 0;\n}","preventionTips":["Return 0 on failure so scroll handlers stop pagination cleanly","Add exponential backoff for repeated pagination failures","Re-authenticate proactively when tokens approach expiry"],"tags":["svelte","pagination","network","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"}