apiRequest's 429 handling ignores Retry-After in HTTP-date form, and its `|| "Rate limited..."` fallback message is dead code
Maintainers usually reply within 1 day
@foxxx009 is already working on this.
Since Sep 28, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- api
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 94
- Avg merge
- 1h 2m
- Merged PRs (30d)
- 25
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MergeFi/frontend
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug testing
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
accessibility bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MergeFi/frontend#835 · 1 comment ·
Maintainers usually reply within 1 day
All issues in MergeFi/frontend
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zapcooking/frontend#946 ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
WiliamRosa/cosmos-semantic-platform#40 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
liberation-data/drivine#733 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
makecindy/cindy#10062 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day