Ionosphere.tv
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: skip stale public Jetstream cursor, start from live

If the cursor is >60s behind, start from now instead of replaying
the full firehose backlog. Prevents the appview from being
permanently behind.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+15 -1
+15 -1
apps/ionosphere-appview/src/public-jetstream.ts
··· 15 15 16 16 const getCursor = (): number | null => { 17 17 const row = db.prepare("SELECT cursor_us FROM _public_cursor WHERE id = 1").get() as any; 18 - return row?.cursor_us ?? null; 18 + const cursor = row?.cursor_us ?? null; 19 + 20 + // If cursor is more than 60 seconds behind, skip to now. 21 + // The public firehose is too large to replay — we'd rather miss 22 + // old comments than be permanently behind. 23 + if (cursor !== null) { 24 + const nowUs = Date.now() * 1000; 25 + const behindS = (nowUs - cursor) / 1e6; 26 + if (behindS > 60) { 27 + console.log(`[Public Jetstream] Cursor ${behindS.toFixed(0)}s behind, skipping to now`); 28 + return null; // null = start from live 29 + } 30 + } 31 + 32 + return cursor; 19 33 }; 20 34 21 35 const setCursor = (cursor: number): void => {