Skip to content

Retries ​

Off by default. Pass retry to repeat the failures worth repeating:

ts
const strapi = new Strapi({
	baseURL: "http://localhost:1337",
	defaultLocale: "en",
	retry: 3, // or { attempts: 3, delay: 300, maxDelay: 10_000 }
});
OptionDefaultMeaning
attemptsthe number you passedExtra attempts after the first request. retry: 3 means up to four requests.
delay300First wait, in milliseconds. Doubles each attempt.
maxDelay10000Cap on the wait, including Retry-After.
statuses408, 429, 500, 502, 503, 504Responses a second attempt can fix. A 400 or 404 is returned as it is.
methodsGET, HEAD, OPTIONSRepeating a POST can create a second document, because the first may have been applied before the response was lost. Opt in with methods: ["POST"] when the endpoint tolerates it.
networktrueRetry when no response arrived. false turns that off.
jitterfalseSpread the waits when many clients retry at once.
onRetrynoneCalled with { attempt, delay, status } before each wait. status is null for a network failure.

Retry-After is honoured, in seconds or as an HTTP date, and capped at maxDelay. Otherwise the wait doubles from delay.

timeout applies per attempt. An aborted init.signal stops the retrying: you asked for the request to stop, not to be repeated.

ts
retry: {
	attempts: 3,
	jitter: true,
	onRetry: ({ attempt, delay, status }) => log.warn({ attempt, delay, status }),
}

Released under the MIT License.