mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
fix: retry HTTP fetch on 408, 409, 420, 429 status codes from the server (#4005)
This commit is contained in:
6
.changeset/tame-grapes-search.md
Normal file
6
.changeset/tame-grapes-search.md
Normal file
@@ -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.
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user