Repository navigation
Fetch the feed once per build and load sponsors in one batch - #106
Conversation
The feed was downloaded three times per build: once each by getShowInfo's and getAllEpisodes's rss-to-json parse, and once more for the raw-XML scan of video and people. The caches held values, not promises, so concurrent first callers fetched again. The feed text is now fetched once per process behind a shared promise (forgotten on failure so a retry refetches), and rss-to-json parses that text through an axios adapter. Episode pages made two sponsor queries each, and every episode renders at two paths. Sponsors and their episode counts now load once per build in lib/sponsors.ts, ordered by episode slug then sponsor id to keep the order the per-episode index lookup gave. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 33 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
Why
We want to merge
media-redesigninto main with confidence, and the review flagged wasted build-time data work. Every build downloaded the RSS feed three times:getShowInfo's parse,getAllEpisodes's parse, and the raw-XML scan for video and people. The caches held values rather than promises, so concurrent first callers fetched again. Each episode page also ran two sponsor queries, and every episode renders at both/<number>and/<slug>.What changed
lib/rss.tsfetches the feed text once per process behind a shared promise, through a smalloncehelper. A failed fetch is forgotten, so the next call tries again. rss-to-json still does the parsing, but an axiosadapterhands it that shared text, so the parsed shape is unchanged.getShowInfoandgetAllEpisodescache their promises the same way.lib/feed-media.tslosesfetchFeedExtras.getAllEpisodesrunsextractVideosByGuidandextractPeopleByGuidon the shared text instead.lib/sponsors.tsloads every episode's sponsors and each sponsor's episode count in one batch per build, the waylib/people.tsbatches people.[episode].astrolooks up its slug there. The batch query orders by(episodeSlug, sponsorId). That matches the order the old per-episode lookup returned through the unique index. The seed has no episode with two sponsors, so the HTML diff can't check this.tests/unit/rss.test.tschecks that concurrent show and episode reads fetch once, and that a failed fetch is retried.Behavior change: the separate video/people fetch used to swallow its own failures and had a 10s timeout. That fetch no longer exists. A feed failure already failed the build through the main parse, so this changes nothing in practice.
Verification
Measurements were taken against a seeded local SQLite DB (263 episodes, 26 sponsor links). Feed requests were counted with a
--requirehook that wrapsfetchandhttps.request. DB queries were counted with a temporary drizzle logger that is not committed. Before and after builds were alternated.astro buildwall timeThe wall times are inconclusive. Machine load averaged 13 to 39 (1-minute) with other builds running, and the order flipped between pairs. Local SQLite queries cost almost nothing, so the query savings matter mainly against remote Turso, where each query is a network round trip. That benefit is inferred, not measured. The other 125
rss.flightcast.comrequests per build are transcript fetches and are unchanged.Output parity: all 1528 files in
.vercel/output/staticare identical before and after, across three before/after pairs, once two per-build random tokens are normalized (sp-icon-*gradient ids and islanduids). The same normalization makes two unchanged builds match each other. 52 pages render a sponsor section both before and after.pnpm lint: cleanastro check: 0 errorspnpm exec vitest run: 32 files, 279 tests passplaywright test tests/e2e/episode.spec.ts --project=chromium: 31 passed🤖 Generated with Claude Code