Build Time Too Long
A push takes about two minutes to deploy, but Astro compiles the site in six seconds. The rest is probably refetching content from scratch.
- Path
- issues/Build-Time-Too-Long.md
- Authors
- Michael Staton
- Augmented with
- Claude Code on Claude Opus 5.5 (1M context)
- Tags
- Issue-Resolution · Build-Performance · Vercel · Astro
Build Time Too Long
Why Care?
Every push to this site takes about two minutes to go live. That’s slow for how little the site is, and it adds up when the work is iterative: a dashboard tweak, a log entry, a typo. Two minutes per push means waiting longer than the edit took.
What we observed (2026-10-04)
| Measurement | Time | Source |
|---|---|---|
pnpm exec astro build locally (no content fetch) |
~6 s (server built in 6.01 s) | local run |
Push → Vercel Preview deployment ready, commit 68ad85a |
~2 min (pushed ~02:04:50Z, ready 02:06:56Z) | GitHub deployments API |
| Same commit, Production deployment | ready 02:09:23Z, ~2.5 min after the Preview | GitHub deployments API |
| For comparison: hope-ai splash on GitHub Pages | 35–43 s per run | gh run list |
The Astro compile isn’t the bottleneck. Whatever is slow happens before it or around it.
Hypotheses, most likely first
-
Every build refetches all content, cold.
pnpm buildispnpm fetch-all && astro build, andfetch-allruns three network fetchers one after another:fetch-context-v.ts: GitHub API, a tree walk plus a request per file, for the repos incontext-v-sources.yamlfetch-essays.ts: GitHub API forlossless-group/lossless-content/essays/fetch-youtube-playlists.ts: YouTube Data API for every playlist URL insrc/content/
Each has a SHA- or TTL-keyed cache (
.context-v-cache/,.essays-cache/,src/data/youtube-playlist-cache.json). But those caches and the fetched output are all gitignored, and Vercel doesn’t keep arbitrary dot-directories between builds. So on Vercel every cache is probably cold every time, and the whole corpus is downloaded on every push. -
Two deployments per push. The same commit got a Preview and then a Production deployment about 2.5 minutes apart. If Production is a full rebuild rather than a promotion, every push pays for the build twice. Check the project’s Git settings for which branch is Production.
-
Unauthenticated or throttled GitHub requests. Both GitHub fetchers send a token only if one is set. Without
GITHUB_TOKENon Vercel, they share a 60-request-an-hour limit, and any backoff or retry would stretch the build. -
Install and function bundling.
pnpm installplus the@astrojs/vercelserver bundle are fixed costs, probably 20–40 s on a warm install cache. Worth measuring, but they can’t explain two minutes alone.
Next steps (measure before fixing)
- Open the Vercel build log for
68ad85aand read the timing of each phase: install, eachfetch-*script,astro build, function bundling. - Locally, run
time pnpm fetch-context -- --freshandtime pnpm fetch-essays -- --freshto see a cold-cache fetch. - Check whether
GITHUB_TOKENis set on the Vercel project. - Check why one push made both a Preview and a Production deployment.
Possible fixes (once measured)
- Keep the fetch caches inside a directory Vercel restores between builds
(e.g. under
node_modules/.cache/), so unchanged content is skipped. - Run the fetchers in parallel rather than in sequence (
fetch-alluses&&). - Skip a fetcher when its source repo’s HEAD SHA hasn’t changed: one API call instead of a tree walk.
- Move content fetching to a scheduled job that commits the result, so a code push doesn’t wait on content.
Related
package.json(build,fetch-allscripts)scripts/fetch-context-v.ts,scripts/fetch-essays.ts,scripts/fetch-youtube-playlists.tscontext-v-sources.yamlastro.config.*(output: 'server',@astrojs/vercel)