Skip to content

Honour Retry-After on 429; cap and jitter the connect retry backoff - #321

Open
aminebalti55 wants to merge 2 commits into
mautrix:mainfrom
aminebalti55:pr/backoff-and-retry-after
Open

Honour Retry-After on 429; cap and jitter the connect retry backoff#321
aminebalti55 wants to merge 2 commits into
mautrix:mainfrom
aminebalti55:pr/backoff-and-retry-after

Conversation

@aminebalti55

Copy link
Copy Markdown

httpclient: honour Retry-After on 429

A 429 was retried on a fixed local schedule (6s, 12s, 18s …) and the Retry-After header was never read, so when the server asked for a longer cooldown the client kept probing on its own shorter one. This uses the header — delta-seconds or HTTP-date — as the floor for the backoff. Unparsable values are treated as absent, so a bad header can't make things worse than no header. Test included.

connector, igconnector: cap and jitter the connect retry backoff

Both connectWithRetry loops slept 1<<attempts seconds with no cap and no jitter. Uncapped, that outgrows any sane wait within a couple of dozen failures; unjittered, every login that fails at the same moment retries in perfect lockstep thereafter. One shared helper in metaid does both (5 min cap, ±20% jitter). Test included.

Independent of #320. Both build and test clean; each commit self-contained.

A 429 was retried on a fixed local schedule (6s, 12s, 18s ...) and the
Retry-After header was never read, so when the server asked for a longer
cooldown the client kept probing on its own shorter one. Use the header,
in either delta-seconds or HTTP-date form, as the floor for the backoff.
Unparsable values are treated as absent so a bad header cannot make things
worse than no header.
Both connectWithRetry loops slept 1<<attempts seconds with no cap and no
jitter. Uncapped, that outgrows any sane wait within a couple of dozen
failures; unjittered, every login that fails at the same moment retries in
perfect lockstep thereafter. Share one helper that does both.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant