diff --git a/.changeset/tame-grapes-search.md b/.changeset/tame-grapes-search.md new file mode 100644 index 0000000000..ed916e4bcf --- /dev/null +++ b/.changeset/tame-grapes-search.md @@ -0,0 +1,6 @@ +--- +"@pnpm/fetch": patch +"pnpm": patch +--- + +HTTP requests should be retried when the server responds with on of 408, 409, 420, 429 status codes. diff --git a/packages/fetch/src/fetch.ts b/packages/fetch/src/fetch.ts index 9b44597663..5ff7e05b85 100644 --- a/packages/fetch/src/fetch.ts +++ b/packages/fetch/src/fetch.ts @@ -34,7 +34,8 @@ export default async function fetchRetry (url: RequestInfo, opts: RequestInit = try { // this will be retried const res = await fetch(url as any, opts) // eslint-disable-line - if ((res.status >= 500 && res.status < 600) || res.status === 429) { + // A retry on 409 sometimes helps when making requests to the Bit registry. + if ((res.status >= 500 && res.status < 600) || [408, 409, 420, 429].includes(res.status)) { throw new ResponseError(res) } else { resolve(res)