diff --git a/app/common/adapter/NPMRegistry.ts b/app/common/adapter/NPMRegistry.ts index 0a5537b3..9638c8d0 100644 --- a/app/common/adapter/NPMRegistry.ts +++ b/app/common/adapter/NPMRegistry.ts @@ -98,6 +98,7 @@ export class NPMRegistry { data: params, dataType: 'json', timing: true, + retry: 3, timeout: this.timeout, followRedirect: true, gzip: true, diff --git a/app/core/service/PackageSyncerService.ts b/app/core/service/PackageSyncerService.ts index 5b6ab41e..237bd6c5 100644 --- a/app/core/service/PackageSyncerService.ts +++ b/app/core/service/PackageSyncerService.ts @@ -173,7 +173,9 @@ export class PackageSyncerService extends AbstractService { logId = data.logId; } catch (err: any) { const status = err.status || 'unknow'; - logs.push(`[${isoNow()}][UP] ❌ Sync ${fullname} fail, create sync task error: ${err}, status: ${status}`); + // 可能会抛出 AggregateError 异常 + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError + logs.push(`[${isoNow()}][UP] ❌ Sync ${fullname} fail, create sync task error: ${err}, status: ${status} ${err instanceof AggregateError ? err.errors : ''}`); logs.push(`[${isoNow()}][UP] ${failEnd}`); await this.taskService.appendTaskLog(task, logs.join('\n')); return;