fix: don't retry fetching missing packages (#7276)

This commit is contained in:
David Rodríguez
2023-11-07 13:16:49 +01:00
committed by GitHub
parent 2dfc8c80af
commit abdf1f2b61
3 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/tarball-fetcher": patch
"pnpm": patch
---
Don't retry fetching missing packages, since the retries will never work [#7276](https://github.com/pnpm/pnpm/pull/7276).

View File

@@ -75,6 +75,7 @@ export function createDownloader (
if (
error.response?.status === 401 ||
error.response?.status === 403 ||
error.response?.status === 404 ||
error.code === 'ERR_PNPM_PREPARE_PKG_FAILURE'
) {
reject(error)

View File

@@ -340,6 +340,38 @@ test('throw error when accessing private package w/o authorization', async () =>
expect(scope.isDone()).toBeTruthy()
})
test('do not retry when package does not exist', async () => {
const scope = nock(registry)
.get('/foo.tgz')
.reply(404)
process.chdir(tempy.directory())
const resolution = {
integrity: tarballIntegrity,
tarball: 'http://example.com/foo.tgz',
}
await expect(
fetch.remoteTarball(cafs, resolution, {
filesIndexFile,
lockfileDir: process.cwd(),
pkg: {},
})
).rejects.toThrow(
new FetchError(
{
url: resolution.tarball,
},
{
status: 404,
statusText: '',
}
)
)
expect(scope.isDone()).toBeTruthy()
})
test('accessing private packages', async () => {
const scope = nock(
registry,