Repository navigation
fix(solid): wait as long as a rate-limiting server asks, and tell the learner while it does - #1089
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-Aftersaid, 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:
rateLimitGate.ts, in the fetch chain made inappUseCases.ts). Every request to a server shares one wait, as the user and as no one; the guest's pod is left out.Retry-After, pauses the server for as long asRetry-Afterasks (seconds or a date, up to 2 min). Where the browser shows noRetry-After, it waits 1 s, doubling up to 1 min, with half of each wait chosen at random.podBusyerror.podBusy: with no status, the app can't tell a rate limit from a server that is down.podNoAnswer, and each try gets fresh deadlines.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.podBusyisn't retried by its query, since the gate already waited for minutes.podWaitsuse cases, over aPodWaitsport the gate implements, asuidoesn't importsolid. 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 whoseRetry-Aftershould be honored sends CORS headers on its 429 and listsRetry-AfterinAccess-Control-Expose-Headers.Tested with a fake fetch and fake timers, covering:
Retry-Afteras seconds and as a date;Retry-Afterholding reads and writes withoutpodNoAnswer, incomposition.Nothing was tried against a real server that rate-limits: no Docker pod test, and no end-to-end journey.
npm run checkpasses on each commit.Not done here, noted for later:
Closes: #1087