open source is social v-it.org
0
fork

Configure Feed

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

explore: switch to live-tail mode, extend stream window to 55s

Jetstream doesn't replay custom lexicon commits via cursor — only
identity/account events replay. Always live-tail (no cursor param)
and rely on D1 UNIQUE constraints for deduplication. Extended stream
window from 25s to 55s to minimize gaps in the 60s cron cycle.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+4 -23
+3 -22
explore/src/index.js
··· 6 6 7 7 export { CursorStore } from './cursor.js'; 8 8 9 - async function getCursor(env) { 10 - const id = env.CURSOR_STORE.idFromName('cursor'); 11 - const stub = env.CURSOR_STORE.get(id); 12 - const res = await stub.fetch('http://cursor/'); 13 - return (await res.text()) || null; 14 - } 15 - 16 - async function saveCursor(env, cursor) { 17 - const id = env.CURSOR_STORE.idFromName('cursor'); 18 - const stub = env.CURSOR_STORE.get(id); 19 - await stub.fetch('http://cursor/', { method: 'PUT', body: cursor }); 20 - } 21 - 22 9 export default { 23 10 async fetch(request, env) { 24 11 const url = new URL(request.url); ··· 30 17 }, 31 18 32 19 async scheduled(event, env, ctx) { 33 - let cursor = await getCursor(env); 34 - // On first run, start 24h ago to catch everything in the Jetstream buffer 35 - if (!cursor) { 36 - cursor = String((Date.now() - 24 * 60 * 60 * 1000) * 1000); 37 - } 38 - const result = await streamEvents(env, cursor); 39 - // Always advance cursor — use latest event time, or current time if no events 40 - const nextCursor = result.latestCursor || String(Date.now() * 1000); 41 - await saveCursor(env, nextCursor); 20 + // Always live-tail (no cursor) — Jetstream doesn't replay custom lexicon 21 + // commits via cursor. D1 UNIQUE constraints handle deduplication. 22 + const result = await streamEvents(env, null); 42 23 }, 43 24 };
+1 -1
explore/src/jetstream.js
··· 6 6 const CAP_COLLECTION = 'org.v-it.cap'; 7 7 const VOUCH_COLLECTION = 'org.v-it.vouch'; 8 8 const JETSTREAM_URL = 'wss://jetstream2.us-east.bsky.network/subscribe'; 9 - const STREAM_DURATION_MS = 25_000; 9 + const STREAM_DURATION_MS = 55_000; 10 10 11 11 function beaconValue(value) { 12 12 return typeof value === 'string' && value.length > 0 ? value : null;