Skip to content

Commit

Permalink
fix: stick to 30s polling
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Jun 2, 2020
1 parent cbedc64 commit 8ae5035
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/lib/poll-import/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { logFailedProjects } from '../../log-failed-projects';
import { logFailedPollUrls } from '../../log-failed-polls';

const debug = debugLib('snyk:poll-import');
const MIN_RETRY_WAIT_TIME = 3000;
const MIN_RETRY_WAIT_TIME = 30000;
const MAX_RETRY_COUNT = 1000;

export async function pollImportUrl(
Expand Down Expand Up @@ -43,13 +43,10 @@ export async function pollImportUrl(
retryCount > 0
) {
await sleep(retryWaitTime);
const increasedRetryWaitTime =
retryWaitTime + retryWaitTime * 0.1 * (MAX_RETRY_COUNT - retryCount);
debug(`Will re-check import task in "${increasedRetryWaitTime}ms"`);
debug(`Will re-check import task in "${retryWaitTime} ms"`);
return await pollImportUrl(
locationUrl,
--retryCount,
increasedRetryWaitTime,
);
}
const projects: Project[] = [];
Expand Down
5 changes: 4 additions & 1 deletion src/scripts/import-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export async function ImportProjects(
if (filteredTargets.length === 0) {
return [];
}
const skippedTargets = targets.length - filteredTargets.length;
debug(`Skipped previously imported ${skippedTargets}/${targets.length} targets`)
for (
let targetIndex = 0;
targetIndex < filteredTargets.length;
Expand All @@ -68,8 +70,9 @@ export async function ImportProjects(
targetIndex,
targetIndex + concurrentTargets,
);
const currentTargets = skippedTargets + targetIndex;
debug(
`Importing batch ${targetIndex} - ${targetIndex +
`Importing batch ${currentTargets} - ${currentTargets +
concurrentTargets} out of ${filteredTargets.length}`,
);
const pollingUrlsAndContext = await importTargets(batch, loggingPath);
Expand Down

0 comments on commit 8ae5035

Please sign in to comment.