diff --git a/.changeset/curvy-feet-applaud.md b/.changeset/curvy-feet-applaud.md new file mode 100644 index 0000000000..3f1b3f5b9d --- /dev/null +++ b/.changeset/curvy-feet-applaud.md @@ -0,0 +1,5 @@ +--- +"@pnpm/fetch": patch +--- + +Some HTTP errors should not be retried [#4917](https://github.com/pnpm/pnpm/pull/4917). diff --git a/packages/fetch/src/fetch.ts b/packages/fetch/src/fetch.ts index 76628db2b4..f201c277e5 100644 --- a/packages/fetch/src/fetch.ts +++ b/packages/fetch/src/fetch.ts @@ -10,6 +10,11 @@ interface URLLike { href: string } +const NO_RETRY_ERROR_CODES = new Set([ + 'SELF_SIGNED_CERT_IN_CHAIN', + 'ERR_OSSL_PEM_NO_START_LINE', +]) + export type RequestInfo = string | URLLike | Request export interface RequestInit extends NodeRequestInit { @@ -42,6 +47,9 @@ export default async function fetchRetry (url: RequestInfo, opts: RequestInit = return } } catch (error: any) { // eslint-disable-line + if (error.code && NO_RETRY_ERROR_CODES.has(error.code)) { + throw error + } const timeout = op.retry(error) if (timeout === false) { reject(op.mainError())