Skip to content

Commit

Permalink
fix: add unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
narol1024 committed Jun 2, 2024
1 parent 2766f10 commit af547e4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/platforms/npm-package/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function readNpmPackageDependencies(packageName: string): Promise<N
});
Promise.race([npmViewPromise, timeoutPromise])
.catch(async error => {
if (error.message === 'Operation timed out' && retryTimes < 3) {
if (error.message === 'Operation timed out' && retryTimes < 10) {
retryTimes += 1;
doReadTask();
} else {
Expand All @@ -61,7 +61,7 @@ export async function countNpmPackageDependants(packageName: string, version: st
const path = version !== null ? `${packageName}/v/${version}` : packageName;
const url = `https://www.npmjs.com/package/${path}?activeTab=dependents&t=${Date.now()}`;
const timeoutPromise = new Promise<void>((_, timeoutReject) => {
countNpmPackageDependantsTimeId = setTimeout(() => timeoutReject(new Error('Operation timed out')), 10000);
countNpmPackageDependantsTimeId = setTimeout(() => timeoutReject(new Error('Operation timed out')), 20000);
});
const fetchPromise = async (): Promise<void> => {
try {
Expand All @@ -88,7 +88,7 @@ export async function countNpmPackageDependants(packageName: string, version: st
};
Promise.race([fetchPromise(), timeoutPromise])
.catch(async error => {
if ((error.message === 'Operation timed out' || error.message === 'Operation failed') && retryTimes < 5) {
if ((error.message === 'Operation timed out' || error.message === 'Operation failed') && retryTimes < 6) {
retryTimes += 1;
doCountTask();
} else {
Expand Down

0 comments on commit af547e4

Please sign in to comment.