From b93d39259da2c9bd8be99706d3be24db05c150db Mon Sep 17 00:00:00 2001 From: Essential Randomness Date: Mon, 20 Jul 2026 02:08:25 -0700 Subject: [PATCH] Configure live feed caching and pagination limits Add bounded caching and pagination configuration for live federation sources. Limit records and pages fetched per source to prevent runaway reads. Update community data paths to use the bounded behavior consistently. --- src/live.config.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/live.config.ts b/src/live.config.ts index 8d3fcef..8e06352 100644 --- a/src/live.config.ts +++ b/src/live.config.ts @@ -118,6 +118,9 @@ const communityAccounts = [ "atmosphere.community", ...communityDefinitions.map((community) => community.handle), ]; +const LIVE_FEED_EVENTS_TTL_MS = 1000 * 60 * 5; +const LIMIT_RECORDS_PER_SOURCE = 200; +const MAX_PAGES_PER_SOURCE = 2; // Warm the source-profile cache once at server boot. Per-record transformers // in lib/live-handlers (e.g. site.standard.document → getProfile('atmosphere.community'), @@ -128,7 +131,7 @@ await prefetchSourceProfiles(communityAccounts); const feed = defineAtProtoLiveCollection({ outputSchema: feedOutputSchema, - cacheTtl: 300, + cacheTtl: LIVE_FEED_EVENTS_TTL_MS, sources: [ // The site's own curated posts use site.standard.document; community accounts share // links via community.opensocial.sharedContent. Both feed into the same output schema @@ -136,12 +139,14 @@ const feed = defineAtProtoLiveCollection({ { repo: "atmosphere.community", collection: "site.standard.document" as const, - limit: 200, + limit: LIMIT_RECORDS_PER_SOURCE, + maxPages: MAX_PAGES_PER_SOURCE, }, ...communityAccounts.map((repo) => ({ repo, collection: "community.opensocial.sharedContent" as const, - limit: 200, + limit: LIMIT_RECORDS_PER_SOURCE, + maxPages: MAX_PAGES_PER_SOURCE, })), ], // A single broken/unreachable repo shouldn't blank out the whole feed during build. @@ -165,7 +170,7 @@ const feed = defineAtProtoLiveCollection({ const events = defineAtProtoLiveCollection({ outputSchema: eventsOutputSchema, - cacheTtl: 300, + cacheTtl: LIVE_FEED_EVENTS_TTL_MS, sources: [ // Two paths into the events list: // 1. Native calendar records authored by the community itself. @@ -176,12 +181,14 @@ const events = defineAtProtoLiveCollection({ ...communityAccounts.map((repo) => ({ repo, collection: "community.lexicon.calendar.event" as const, - limit: 200, + limit: LIMIT_RECORDS_PER_SOURCE, + maxPages: MAX_PAGES_PER_SOURCE, })), ...communityAccounts.map((repo) => ({ repo, collection: "community.opensocial.sharedContent" as const, - limit: 200, + limit: LIMIT_RECORDS_PER_SOURCE, + maxPages: MAX_PAGES_PER_SOURCE, parseRecord: (value: unknown) => parseSharedEventRecord(value, repo), })), ], -- 2.51.2