apiRequest's 429 handling ignores Retry-After in HTTP-date form, and its `|| "Rate limited..."` fallback message is dead code
I maintainer di solito rispondono entro 1 giorno
@foxxx009 ci sta già lavorando.
Dal 28/9/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- api
Direzione di ricerca
The 429 branch is in apiRequest() in src/lib/api.ts, where the Retry-After header is parsed with parseInt and the || fallback is dead. Two open pull requests (#573 and #586) already target this, so read them and the thread before starting. Done means HTTP-date and delay-seconds values both populate the wait message and ApiRequestError.retryAfter, the fallback message is reachable, and unit tests cover the four header cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
src/lib/api.ts → apiRequest(), from the rate-limit handling added in #44:
if (res.status === 429) {
const retryAfter = res.headers.get("Retry-After");
const seconds = retryAfter ? parseInt(retryAfter, 10) : NaN;
const waitMsg = Number.isFinite(seconds)
? ` Please wait ${seconds} second${seconds === 1 ? "" : "s"} before trying again.`
: "";
throw new ApiRequestError(
`You're doing that too fast.${waitMsg}` || `Rate limited. Please try again later.`,
429,
Number.isFinite(seconds) ? seconds : undefined,
);
}
- HTTP-date
Retry-Afteris dropped. RFC 9110 §10.2.3 allowsRetry-Afterto be either delay-seconds or an HTTP-date, such asRetry-After: Wed, 21 Oct 2026 07:28:00 GMT, which proxies and CDNs commonly send.parseInt("Wed, 21 Oct…", 10)isNaN, so the wait time disappears from both the message andApiRequestError.retryAfter. Callers that readretryAfterto throttle retries getundefined. - The fallback message is unreachable. The left side of
||is a template literal that always starts with"You're doing that too fast.", so it's always truthy."Rate limited. Please try again later."can never be used, which suggests the intended "no wait info" message was lost.
Suggested fix
- Parse both forms. Use the seconds if
/^\d+$/matches. Otherwise useDate.parse(value)and computeMath.max(0, Math.ceil((date - Date.now()) / 1000)). - Choose the message explicitly: the "wait N seconds" wording when seconds are known, and the plain fallback otherwise. Remove the dead
||. - Add unit tests for delay-seconds, an HTTP-date, a missing header and a garbage header value.
lib/api.tshas limited coverage (#370).
Related: #44, #370.
- Lingua principale
- TypeScript
- Stelle
- 1
- Fork
- 94
- Merge medio
- 1h 2m
- PR unite (30g)
- 25
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MergeFi/frontend
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
bug testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
accessibility bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MergeFi/frontend#835 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MergeFi/frontend
Issue simili
-
ログイン中の404画面にヘッダーとナビを出すApertaCodex使用可 コード
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ryuki-moro/Nicomaru#218 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sveltejs/svelte-eslint-parser#1008 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
silverbucket/inbox-rs#351 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: The H2 series' and the H3C's fan 3 is labelled "Chamber Fan", Bambu calls it the exhaust fanApertaarea:ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
bug front P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
invoicerr-app/invoicerr#964 ·
I maintainer di solito rispondono entro 1 giorno