Repository navigation
fix(release): read ffmpeg asset names from BtbN and back off on 429 - #102
Conversation
…ack off on 429 The Release Snapshot job failed for every target but one: - BtbN's `latest` release dropped the n9.0 series, so the three hard-coded Linux and Windows URLs answered 404. The asset names now come from the release's own checksums.sha256. SERIES (n9.1) stays the preferred pin; when BtbN drops it, the newest release series still published is staged, never master, with a warning. Each archive is checked against the listed digest. - osxexperts.net answered 429 because both macOS targets asked it at once and retried after 2 and 4 seconds, inside its 5-second Retry-After. Archives on one host are now fetched one at a time, a 429 waits out Retry-After with a 5/15/45/90 second backoff, and a host is waited on for at most four minutes. A 404 is no longer retried. RAWBACK_FFMPEG_CACHE_DIR keeps digest-pinned archives between runs, and the snapshot workflow stores that directory with actions/cache. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRgCXueUSYRM2TSmhGd
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
The host-budget test listed the requests in the order the targets were declared, but the two targets are staged concurrently and either can queue first, which is what happened on the CI runner. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRgCXueUSYRM2TSmhGd
|
Status of the two failed checks on Build and Test — mine, fixed in GoReleaser snapshot — the BtbN half is fixed; the macOS half is blocked upstream.
Generated by Claude Code |
☁️ Claude Code cloud · Fix FFmpeg staging in snapshot releasesDiagnosed and fixed the recurring Release Snapshot failures by hardening FFmpeg artifact staging, adding tests, and updating CI and developer documentation.
27.1M tokens: 2.3K input · 139.3K output · 26.3M cache read · 590K cache write 📝 AI summaryInvestigated the Added or updated coverage in View this session on ShellTime → Updated 2026-12-05 11:39 UTC by ShellTime · totals for the whole session so far · the session page is visible to its owner |
| ], | ||
| source: { | ||
| pinned: [ | ||
| { url: 'https://www.osxexperts.net/ffmpeg80intel.zip' }, |
There was a problem hiding this comment.
Important: none of the four macOS pinned archives carries a sha256, so the macOS cache never takes effect. pinned() sets cacheDir = archive.sha256 === undefined ? undefined : staging.cacheDir, so in production nothing is read from or written to RAWBACK_FFMPEG_CACHE_DIR. The cache directory stays empty, hashFiles(...) != '' is false, the Save step is skipped, and the snapshot build still fetches all four archives from osxexperts.net and can still hit the 429s this PR set out to avoid. This also contradicts docs/development.md, which says each archive has "its SHA-256 in the script". The tests pass only because they build pins with sha256 themselves. Fix: add the real digest to each of the four URLs (lines 106, 107, 117 and 118). Alternatively, fail loudly or log when a pinned archive has no digest.
| // Written beside its final name and moved, so a run that is cancelled | ||
| // mid-copy cannot leave half an archive for the next one to find. | ||
| await mkdir(cacheDir, { recursive: true }) | ||
| await copyFile(destination, `${kept}.partial`) |
There was a problem hiding this comment.
Nit (optional): writing the cache copy is not best-effort. mkdir, copyFile and rename run after a successful download and verification, so a full disk or unwritable RAWBACK_FFMPEG_CACHE_DIR makes the whole target fail even though the archive is good. Fix: wrap the cache write in try/catch, warn, and return fetched anyway.
| } | ||
| const asked = Math.min(result.retryAfterSeconds ?? 0, RETRY_AFTER_CAP_SECONDS) | ||
| // Up to a fifth longer, so runs that were refused together do not return together. | ||
| return Math.max(backoff, asked) * (1 + jitter / 5) |
There was a problem hiding this comment.
Nit (optional): jitter is applied after the Retry-After cap. A host asking for 120s or more waits up to 144s, which is more than the documented RETRY_AFTER_CAP_SECONDS. Two such waits (288s) exceed HOST_BACKOFF_BUDGET_SECONDS (240), so the second wait is refused. The test only covers random: () => 0. Fix: apply the jitter to the backoff only, or cap after jittering.
|
|
||
| /** Only the seconds form: an HTTP date would need this machine's clock to agree with the host's. */ | ||
| export function parseRetryAfter(headers: string): number | undefined { | ||
| const values = [...headers.matchAll(/^retry-after:[ \t]*(\d+)[ \t]*\r?$/gim)] |
There was a problem hiding this comment.
Nit (optional): --dump-header with --location writes every hop's headers, and this takes the last Retry-After in the file. A Retry-After on an intermediate redirect response is taken as the final answer's. This only matters if a redirect hop sends the header and the final response does not. Fix: only read the final header block, the part after the last blank line.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 582b4aa943
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| { url: 'https://www.osxexperts.net/ffmpeg80intel.zip' }, | ||
| { url: 'https://www.osxexperts.net/ffprobe80intel.zip' }, |
There was a problem hiding this comment.
Add digest pins so the snapshot archive cache can operate
All four production macOS archives omit sha256, so pinned() unconditionally disables caching for them and pruneCache() removes any restored copies. Consequently, setting RAWBACK_FFMPEG_CACHE_DIR in Release Snapshot never saves or reuses an archive: every run still downloads all four files from the rate-limited host, contrary to the new workflow comments and development documentation. Populate the four digest pins before relying on the cache to reduce requests. AGENTS.md requires documentation to describe actual current behavior.
AGENTS.md reference: AGENTS.md:L127-L128
Useful? React with 👍 / 👎.
Summary
Release Snapshothas failed onmainevery night since 2026-11-28, and on every pull request, inscripts/stage-ffmpeg.ts.latestrelease keeps only the two newest release branches and droppedn9.0, which the script hard-coded. The asset names now come from the release's ownchecksums.sha256.SERIES(n9.1) stays the preferred pin; when BtbN drops it, the script stages the newest release series still published, nevermaster, and warns in the log and the run summary. Every archive is checked against the digest the list gives.Retry-After. Archives on one host are now fetched one at a time; a 429, a 5xx or a stalled transfer backs off 5/15/45/90 s (orRetry-Afterif longer); a host is waited on for at most four minutes in total. A 404 is no longer retried.RAWBACK_FFMPEG_CACHE_DIRkeeps digest-pinned archives between runs. The snapshot workflow stores that directory withactions/cache(restore and save split, so a run that got some archives before a refusal keeps them).release.ymlis unchanged: a published release always downloads.The script keeps what it guaranteed before: LGPL static builds, a release series, version-pinned macOS URLs, the stall limit, the size and archive-signature checks, and a report of every failed host.
Still to come on this PR
The SHA-256 pins for the four macOS archives. They will be copied from this PR's first
Release Snapshotrun, which logs the digest of each download, and added in a follow-up commit. Until then the macOS archives are checked by size and signature only, as onmain, and are not cached.Testing
bun run checkpasses (809 tests, including the 25 new ones intest/stage-ffmpeg.test.ts).bun run scripts/stage-ffmpeg.tsagainst the real hosts staged Linux x64, Linux arm64 and Windows x64 fromn9.1, with digests matchingchecksums.sha256; the staged Linuxffmpeg -versionreportsn9.1with no--enable-gpl.bun run build:all. osxexperts.net refuses the machine this was developed on, so this PR'sRelease Snapshotrun is the test for those.Generated by Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.