From 7d14c3409e5e528e6c5859ab08aaf9e6549736b2 Mon Sep 17 00:00:00 2001 From: Moepchi Date: Sun, 11 Oct 2026 15:24:01 +0000 Subject: [PATCH] Wait longer for the release preview image before giving up GitHub's image service answered 429 for the whole 20 seconds after the v0.16.0-beta.5 release, so the Bluesky post went out without a card. Back off 15/30/45/60 s and honor Retry-After (capped at 60 s), which fits in the job's 5-minute timeout. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU --- .github/scripts/announce-release.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/scripts/announce-release.py b/.github/scripts/announce-release.py index 7a8f6b1..f9027b7 100644 --- a/.github/scripts/announce-release.py +++ b/.github/scripts/announce-release.py @@ -47,16 +47,23 @@ def xrpc(method: str, payload: dict | bytes, token: str | None = None, content_t return json.load(res) -def fetch(url: str, retries: int = 2) -> tuple[bytes, str]: +def fetch(url: str, attempt: int = 1) -> tuple[bytes, str]: req = urllib.request.Request(url, headers={"User-Agent": "webspeak3-release-announcer"}) try: with urllib.request.urlopen(req, timeout=30) as res: return res.read(), res.headers.get_content_type() except urllib.error.HTTPError as err: - if err.code != 429 or not retries: # GitHub's image service throttles bursts now and then + # GitHub's image service throttles right after a release, often for over a minute. + # 15+30+45+60 s stays well inside the job's 5-minute timeout. + if err.code != 429 or attempt > 4: raise - time.sleep(10) - return fetch(url, retries - 1) + wait = 15 * attempt + retry_after = err.headers.get("Retry-After", "") + if retry_after.isdigit(): + wait = min(int(retry_after), 60) + print(f"Preview image throttled (429), retrying in {wait} s.") + time.sleep(wait) + return fetch(url, attempt + 1) def link_card(release: dict, text: str) -> dict: