Skip to content

Fetch the feed once per build and load sponsors in one batch - #106

Merged
RobbieTheWagner merged 1 commit into
media-redesignfrom
perf/build-data
Dec 1, 2026
Merged

RobbieTheWagner merged 1 commit into
media-redesignfrom
perf/build-data

Conversation

@RobbieTheWagner

Copy link
Copy Markdown
Member

Why

We want to merge media-redesign into 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.ts fetches the feed text once per process behind a shared promise, through a small once helper. A failed fetch is forgotten, so the next call tries again. rss-to-json still does the parsing, but an axios adapter hands it that shared text, so the parsed shape is unchanged. getShowInfo and getAllEpisodes cache their promises the same way.
  • lib/feed-media.ts loses fetchFeedExtras. getAllEpisodes runs extractVideosByGuid and extractPeopleByGuid on the shared text instead.
  • New lib/sponsors.ts loads every episode's sponsors and each sponsor's episode count in one batch per build, the way lib/people.ts batches people. [episode].astro looks 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.
  • New tests/unit/rss.test.ts checks 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 --require hook that wraps fetch and https.request. DB queries were counted with a temporary drizzle logger that is not committed. Before and after builds were alternated.

before after
Feed XML downloads per build 3 (2 axios + 1 fetch) 1
DB queries per build 579 (525 sponsor + 52 count + 2 people) 4
astro build wall time 103.1s, 62.8s, 49.7s 60.5s, 56.6s, 65.5s

The 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.com requests per build are transcript fetches and are unchanged.

Output parity: all 1528 files in .vercel/output/static are identical before and after, across three before/after pairs, once two per-build random tokens are normalized (sp-icon-* gradient ids and island uids). The same normalization makes two unchanged builds match each other. 52 pages render a sponsor section both before and after.

  • pnpm lint: clean
  • astro check: 0 errors
  • pnpm exec vitest run: 32 files, 279 tests pass
  • playwright test tests/e2e/episode.spec.ts --project=chromium: 31 passed

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
starpod Ready Ready Preview Nov 30, 2026 8:26pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8bdf42d and a3ebea3.

Files selected for processing: 5

  • packages/starpod/src/lib/feed-media.ts
  • packages/starpod/src/lib/rss.ts
  • packages/starpod/src/lib/sponsors.ts
  • packages/starpod/src/pages/[episode].astro
  • tests/unit/rss.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@RobbieTheWagner

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@RobbieTheWagner

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@RobbieTheWagner
RobbieTheWagner merged commit 80ea3e7 into media-redesign Dec 1, 2026
9 checks passed
@RobbieTheWagner RobbieTheWagner added the enhancement New feature or request label Dec 1, 2026

This branch was successfully deployed

1 active deployment
Preview — a3ebea3e Deployed Nov 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant