Skip to content

fix(solid): wait as long as a rate-limiting server asks, and tell the learner while it does - #1089

Merged
ixuz merged 4 commits into
mainfrom
fix/rate-limit
Nov 28, 2026
Merged

ixuz merged 4 commits into
mainfrom
fix/rate-limit

Conversation

@ixuz

@ixuz ixuz commented Nov 28, 2026

Copy link
Copy Markdown
Member

What and why

A pod that rate-limits got retries at the app's own pace, never the pace the server asked for. Every query retried a failed read 1 s, 2 s and 4 s later, all on the same schedule, whatever the server's Retry-After said, and writes weren't retried at all. A screen's reads went to the pod in one burst, which was enough to be refused on solidcommunity.net (#601). While this went on, the screen only showed that it was loading, and the error at the end was "Something went wrong" with the raw HTTP error as its details.

Four commits:

  • One wait per server (rateLimitGate.ts, in the fetch chain made in appUseCases.ts). Every request to a server shares one wait, as the user and as no one; the guest's pod is left out.
    • How long it waits: a 429, or a 503 with Retry-After, pauses the server for as long as Retry-After asks (seconds or a date, up to 2 min). Where the browser shows no Retry-After, it waits 1 s, doubling up to 1 min, with half of each wait chosen at random.
    • What is sent again: a request refused with 429 is sent again after the wait, whatever its method. A 503 is sent again only for reads, since a write may have been made. After 3 min or 6 tries it fails with the new podBusy error.
    • A 429 without CORS headers, as in Lots of CORS and 429 errors on https://solidcommunity.net #601, reaches the app as a network error with no status. It counts as a refusal only while the browser is online, and only while the server's wait lasts, within a minute of its last refusal, or as the third such failure within 2 s. So a single dropped connection still shows as one. When the gate gives up on such failures, the network error is shown, not podBusy: with no status, the app can't tell a rate limit from a server that is down.
    • The gate sits outside the read deadlines, so a read waiting there isn't given up as podNoAnswer, and each try gets fresh deadlines.
  • At most six requests at once to the user's pod. A turn ends when the answer's headers arrive or the request fails, before any next try, or after 30 s (TURN_MS) while the request goes on, so a server that never answers can't hold turns for good. Nothing on a request's way to the gate makes a request as the user while one holds a turn, so none waits for a turn it holds itself. Reads as no one share the waits but take no turns, since they have their own limits.
  • Query retries with randomness. A retry waits from 1 s, doubling up to 30 s, with half of each wait chosen at random. A read that fails with podBusy isn't retried by its query, since the gate already waited for minutes.
  • Telling the learner. Above every screen, a polite status line names each server whose wait lasts and counts down: "The server pod.example asked Solid Memo to slow down. Trying again in 40 s." A wait started only by failures with no status says the server isn't answering for now instead. A screen reader hears each wait once, as it starts or grows, not every second. The screens read the waits through new podWaits use cases, over a PodWaits port the gate implements, as ui doesn't import solid. The messages are in every language the app speaks.

Docs:

  • docs/architecture.md, "A request on its way to a pod": the diagram and text include the gate.
  • docs/boundaries.md: read deadlines start when a read is sent.
  • docs/interop.md, new section "A server that rate-limits": a server whose Retry-After should be honored sends CORS headers on its 429 and lists Retry-After in Access-Control-Expose-Headers.

Tested with a fake fetch and fake timers, covering:

  • 429s with and without CORS headers;
  • Retry-After as seconds and as a date;
  • writes sent again on 429 and not on a 503;
  • each server keeping its own wait;
  • the six-at-once limit, and a turn given up after 30 s;
  • a 60 s Retry-After holding reads and writes without podNoAnswer, in composition.

Nothing was tried against a real server that rate-limits: no Docker pod test, and no end-to-end journey. npm run check passes on each commit.

Not done here, noted for later:

Closes: #1087

ixuz added 4 commits November 28, 2026 10:39
…as too many

A pod that rate-limits got retries at the app's own pace: each query
retried 1 s, 2 s and 4 s later whatever the server's Retry-After said,
every query on the same schedule, and writes weren't retried at all.
The retries landed in the next rate-limit window together.

A rate-limit gate in the fetch chain now keeps one wait per server,
shared by every request to it, as the user and as no one. A 429, or a
503 with Retry-After, pauses the server for as long as Retry-After asks
(up to two minutes), or for a jittered backoff from 1 s up to a minute
where the browser shows no Retry-After. A request refused with 429 is
sent again after the wait, whatever its method, and so is a read
refused with 503; past three minutes or six tries it fails with the new
podBusy error. A network failure with no status, as a 429 without CORS
headers shows, counts as a refusal only while the server's wait lasts,
within a minute of its last refusal, or as the third within two
seconds, so a single dropped connection is still shown as one.

The gate sits outside the read deadlines, so a read waiting there isn't
given up as podNoAnswer for the time it waits. The interop docs say
which CORS headers a server's 429 needs for its Retry-After to be read.

Refs: #1087
A screen's reads went to the pod all at once, with nothing limiting how
many, and a server that rate-limits took them as one burst: the deck
list of an instance with several decks was enough to be refused on
solidcommunity.net. Over HTTP/2 a browser sends them together.

The rate-limit gate now gives the user's requests turns, at most six
under way to one server at once, as many as a browser asks one server
for over HTTP/1.1. A turn ends once the answer's headers come or the
request fails, before any next try, so a body read slowly holds no
turn. Nothing the requests pass on their way to the gate makes a
request as the user while one holds a turn, so none waits for a turn
it holds itself. Reads as no one share the servers' waits, and take
no turn, as they have limits and budgets of their own.

Refs: #1087
Every query retried a failed read 1 s, 2 s and 4 s later, TanStack
Query's default with no randomness, so the reads a screen made together
were tried again together, into the same server's rate limit.

A retry now waits from 1 s, doubling up to 30 s as before, but half of
each wait is chosen at random. A read that fails with podBusy isn't
retried by its query: the rate-limit gate already waited for its server
and tried it again for minutes, and a try more at once would only go
into the same limit.

Refs: #1087
While the app waited on a rate-limited pod, the screen only showed that
it was loading, and nothing said the server had asked the app to slow
down; reloading at once sent another burst into the same limit.

Above every screen, a polite status line now names each server whose
wait lasts and counts down to the next try: "The server pod.example
asked Solid Memo to slow down. Trying again in 40 s." A wait started
only by failures with no status says the server isn't answering for
now instead, since the app can't tell a rate limit without CORS headers
from a server that is down. The line tells a screen reader of each wait
once, as it starts or grows, not each second. The screens read the
waits through the new podWaits use cases, over a PodWaits port the
rate-limit gate implements, as ui doesn't import solid. The messages
are in every language the app speaks.

Closes: #1087
@ixuz ixuz added bug Something isn't working interop i18n labels Nov 28, 2026
@ixuz
ixuz enabled auto-merge November 28, 2026 11:01
@ixuz
ixuz added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 8783caa Nov 28, 2026
57 checks passed
@ixuz
ixuz deleted the fix/rate-limit branch November 28, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working i18n interop

Projects

None yet

1 participant