From 236121d63234991ad8ae3928f56422c2588a0488 Mon Sep 17 00:00:00 2001 From: Brett Kyle Date: Thu, 19 Dec 2024 21:10:26 +0000 Subject: [PATCH] Continue RequestError --- build-filtered-data.mjs | 60 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/build-filtered-data.mjs b/build-filtered-data.mjs index 8fbd0703..55b521ab 100644 --- a/build-filtered-data.mjs +++ b/build-filtered-data.mjs @@ -195,37 +195,43 @@ async function filterDeps() { console.log(`${performance.now()}: Analysis BEGIN`) for (const repo of rawDeps.all_public_dependent_repos) { - console.log(`${performance.now()}: Getting repo data...`) - const repoData = await analyseRepo(repo) - if (repoData) { - builtData.push(repoData) - batchCounter++ - } - console.log(`${performance.now()}: Analysis of ${repo.name} complete`) + try { + console.log(`${performance.now()}: Getting repo data...`) + const repoData = await analyseRepo(repo) + if (repoData) { + builtData.push(repoData) + batchCounter++ + } + console.log(`${performance.now()}: Analysis of ${repo.name} complete`) + + const index = rawDeps.all_public_dependent_repos.findIndex( + (item) => item === repo + ) + console.log( + `This was repo number ${index + 1} of ${ + rawDeps.all_public_dependent_repos.length + }` + ) - const index = rawDeps.all_public_dependent_repos.findIndex( - (item) => item === repo - ) - console.log( - `This was repo number ${index + 1} of ${ - rawDeps.all_public_dependent_repos.length - }` - ) + const remaining = await getRemainingRateLimit() + console.log(`${remaining} remaining on rate limit`) + } catch (error) { + if (error instanceof RequestError) { + continue + } + } + if (batchCounter >= batchSize) { + await writeBatchToFiles(builtData) + builtData.length = 0 + batchCounter = 0 + } - const remaining = await getRemainingRateLimit() - console.log(`${remaining} remaining on rate limit`) - } - if (batchCounter >= batchSize) { - await writeBatchToFiles(builtData) - builtData.length = 0 - batchCounter = 0 - } + if (builtData.length > 0) { + await writeBatchToFiles(builtData) + } - if (builtData.length > 0) { - await writeBatchToFiles(builtData) + console.log(`${performance.now()}: We're done!`) } - - console.log(`${performance.now()}: We're done!`) } async function writeBatchToFiles(builtData) {