Files
pnpm/cli/default-reporter/test/reportingRequestRetry.ts
Zoltan Kochan 6c480a4375 perf: replace node-fetch with undici (#10537)
Replace node-fetch with native undici for HTTP requests throughout pnpm.

Key changes:
- Replace node-fetch with undici's fetch() and dispatcher system
- Replace @pnpm/network.agent with a new dispatcher module in @pnpm/network.fetch
- Cache dispatchers via LRU cache keyed by connection parameters
- Handle proxies via undici ProxyAgent instead of http/https-proxy-agent
- Convert test mocking from nock to undici MockAgent where applicable
- Add minimatch@9 override to fix ESM incompatibility with brace-expansion
2026-03-29 12:44:00 +02:00

36 lines
904 B
TypeScript

import { toOutput$ } from '@pnpm/cli.default-reporter'
import { requestRetryLogger } from '@pnpm/core-loggers'
import {
createStreamParser,
} from '@pnpm/logger'
import { firstValueFrom } from 'rxjs'
import { formatWarn } from '../src/reporterForClient/utils/formatWarn.js'
test('print warning about request retry', async () => {
const output$ = toOutput$({
context: {
argv: ['install'],
},
streamParser: createStreamParser(),
})
requestRetryLogger.debug({
attempt: 2,
error: {
name: 'Error',
message: 'Connection failed',
code: 'ECONNREFUSED',
},
maxRetries: 5,
method: 'GET',
timeout: 12500,
url: 'https://foo.bar/qar',
})
expect.assertions(1)
const output = await firstValueFrom(output$)
expect(output).toBe(formatWarn('GET https://foo.bar/qar error (ECONNREFUSED). Will retry in 12.5 seconds. 4 retries left.'))
})