Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Nov 30, 2024
1 parent 433e692 commit d0da939
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/common/ErrorUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const TimeoutErrorNames = [
'ConnectionError',
'ConnectTimeoutError',
'BodyTimeoutError',
'ResponseTimeoutError',
];

export function isTimeoutError(err: Error) {
Expand Down
10 changes: 8 additions & 2 deletions app/common/adapter/NPMRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
HttpClientResponse,
} from 'egg';
import { PackageManifestType } from '../../repository/PackageRepository';
import { isTimeoutError } from '../ErrorUtil';

type HttpMethod = HttpClientRequestOptions['method'];

Expand Down Expand Up @@ -52,9 +53,14 @@ export class NPMRegistry {
// large package: https://r.cnpmjs.org/%40procore%2Fcore-icons
// https://r.cnpmjs.org/intraactive-sdk-ui 44s
const authorization = this.genAuthorizationHeader(optionalConfig?.remoteAuthToken);
return await this.request('GET', url, undefined, { timeout: 120000, headers: { authorization } });
return await this.request('GET', url, undefined, {
timeout: 120000,
headers: { authorization },
});
} catch (err: any) {
if (err.name === 'ResponseTimeoutError') throw err;
if (isTimeoutError(err)) {
throw err;
}
lastError = err;
}
retries--;
Expand Down

0 comments on commit d0da939

Please sign in to comment.