Skip to content

Commit f784202

Browse files
committed
Add retry logic to batch purl api use
1 parent 6d9c92a commit f784202

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from 'node:path'
66
import readline from 'node:readline'
77

88
import abortSignal from '@socketsecurity/registry/lib/constants/abort-signal'
9+
import { pRetry } from '@socketsecurity/registry/lib/promises'
910

1011
// @ts-ignore: Avoid TS import attributes error.
1112
import rootPkgJson from '../package.json' with { type: 'json' }
@@ -411,7 +412,12 @@ export class SocketSdk {
411412
): AsyncGenerator<BatchPackageFetchResultType> {
412413
let res: IncomingMessage | undefined
413414
try {
414-
res = await this.#createBatchPurlRequest(queryParams, componentsObj)
415+
res = await pRetry(
416+
() => this.#createBatchPurlRequest(queryParams, componentsObj),
417+
{
418+
retries: 4
419+
}
420+
)
415421
} catch (e) {
416422
return await this.#handleApiError<'batchPackageFetch'>(e)
417423
}

0 commit comments

Comments
 (0)