Skip to content

fix(client): retry HTTP 429 with Retry-After/backoff - #2

Closed
fredericosantos wants to merge 1 commit into
perf/parallel-commentsfrom
fix/retry-429
Closed

fredericosantos wants to merge 1 commit into
perf/parallel-commentsfrom
fix/retry-429

Conversation

@fredericosantos

@fredericosantos fredericosantos commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Every olcli command starts by fetching /project to get a CSRF token, so a short burst of commands (for example scripted comments add calls) gets Failed to fetch projects page: 429 from Overleaf and exits 1.

Change

httpRequest is where every request goes through, so the fix is there: on HTTP 429 it retries up to 5 times, honoring Retry-After when present and otherwise backing off 1 s, 2 s, 4 s, 8 s, 16 s with ±25% jitter (about 30 s in total). A 429 means the request was rejected, not processed, so retrying is safe for every method. CHANGELOG entry included.

This is stacked on the socket-pool PR, so it only contains one commit of its own.

Tests

npm test: 89 passing (one more than the socket-pool branch). The unit test starts a local server that answers 429 twice and then 200 (expects status 200 after 3 calls), and one that always answers 429 (expects status 429 after 6 calls).

Tested against real Overleaf rate limiting

I provoked real 429s on my account with olcli whoami (it fetches /project like every command), one trial per row, waiting for the limit to clear between runs:

scenario without retry with this change
30 calls back to back 14 ok, 16 failed (24 s total) 29 ok, 1 failed (73 s total)
20 calls in parallel 8 ok 9 ok
40 calls in parallel 0 ok 0 ok

So it helps scripts that run commands one after another, at the cost of waiting. It does not help a large parallel burst even with the longer window and jitter (20 parallel calls: 9 of 20 succeeded either way), because the retries are themselves requests that keep the limit drained. Before the schedule was lengthened, failed calls took about 8.5 s, which matched 3 retries at 1 s, 2 s and 4 s. Overleaf sends no Retry-After header on these 429s, so the fallback schedule is what applies in practice.

What I haven't verified

  • One trial per scenario, one account.
  • One trial per scenario; the sequential numbers (26 of 30 on the old 3-retry schedule, 29 of 30 on this one) are from single runs.
  • It doesn't cache the CSRF token between CLI invocations, which would avoid most of these requests in the first place. That would be a separate change.
  • Separately, olcli whoami reports Session invalid and exits 0 when the cause is a 429. Not touched here.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fredericosantos

Copy link
Copy Markdown
Owner Author

Superseded by aloth#63 (rebuilt on v0.16.2).

@fredericosantos
fredericosantos deleted the fix/retry-429 branch November 14, 2026 10:13
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.

1 participant