Skip to content

Retry requests that Overleaf rate limits (HTTP 429) - #63

Merged
aloth merged 3 commits into
aloth:mainfrom
fredericosantos:fix/retry-429-upstream
Nov 15, 2026
Merged

aloth merged 3 commits into
aloth:mainfrom
fredericosantos:fix/retry-429-upstream

Conversation

@fredericosantos

Copy link
Copy Markdown
Contributor

Overleaf answers a burst of requests with HTTP 429, and the limit lasts about 25 seconds. A command that sends a few requests in a row (adding a comment and then reading the threads back, for example) can fail with "Overleaf is rate limiting requests" although waiting a little would have worked.

Change

httpRequest now retries a 429 up to 5 times, after 1, 2, 4, 8 and 16 seconds (about 30 s in all), with ±25% jitter so parallel requests don't retry in step. When Overleaf sends Retry-After, that wins. A 429 is sent before anything is done, so the retry is safe for every method. --verbose logs each retry.

The extra sockets of the doc-joining pool opt out (retryOn429: false): the pool already drops a socket that gets a 429, and making each one wait 30 s first would undo that. The first socket still retries, because the pool can't work without it.

Tests

npm test goes from 240 to 241. The new test runs a local HTTP server that answers 429 with Retry-After: 0: two 429s then a 200 gives 200 after 3 requests, a server that never stops gives 429 after 6, and retryOn429: false gives 429 after 1. Lint is unchanged at 76 warnings. CHANGELOG entry included.

What I haven't verified

  • The 25 s figure comes from my own account hitting the limit while testing; I don't know Overleaf's actual policy, or whether it differs per plan or instance.
  • I've never seen Overleaf send Retry-After; that branch is only covered by the local test.

Overleaf answers bursts with 429 before doing anything, so a retry is
safe for every method. Wait 1, 2, 4, 8 and 16 s with jitter, or
Retry-After when sent. The extra pool sockets opt out, so a rate-limited
pool still shrinks at once.
A Retry-After value from the server was used as is, so a 429 with Retry-After: 3600 would make olcli wait an hour before the retry. The wait from Retry-After is now capped at 60 seconds; a missing, non-numeric or negative value falls back to the exponential backoff as before. The computation moves into retryDelayMs, and a test next to the existing 429 test checks the cap both on the helper and end to end with a server sending Retry-After: 3600 and a stubbed setTimeout.
@aloth
aloth merged commit a40a4ce into aloth:main Nov 15, 2026
2 checks passed
@aloth

aloth commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Thanks, merged. Before merging I added one commit that caps Retry-After at 60 seconds, with a test next to yours. Ships in 0.17.0.

aloth added a commit that referenced this pull request Nov 15, 2026
Set version 0.17.0 in package.json, package-lock.json, CITATION.cff and server.json, and fold the Unreleased CHANGELOG entries of #63, #64, #65 and #67 into the 0.17.0 section dated 2026-11-15.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants