fix: log more info on HTTP error (#4917)

This commit is contained in:
Zoltan Kochan
2022-07-17 18:03:57 +03:00
committed by GitHub
parent 532d5eb79e
commit e018a8b140
2 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/fetch": patch
---
Some HTTP errors should not be retried [#4917](https://github.com/pnpm/pnpm/pull/4917).

View File

@@ -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())