From 8ce89db6e3f4225b16c503a404c621a59b85f895 Mon Sep 17 00:00:00 2001 From: CNCF-bot Date: Tue, 30 May 2023 09:05:46 +0100 Subject: [PATCH] changes --- tools/apiClients.js | 2 +- tools/repos.js | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tools/apiClients.js b/tools/apiClients.js index 4c5d3db9..bda7fe32 100644 --- a/tools/apiClients.js +++ b/tools/apiClients.js @@ -128,7 +128,7 @@ module.exports.CrunchbaseClient = ApiClient({ module.exports.GithubClient = ApiClient({ baseURL: 'https://api.github.com', - retryStatuses: [403], // Github returns 403 when rate limiting. + retryStatuses: [401, 403], // Github returns 403 when rate limiting. delayFn: error => { const rateLimitRemaining = parseInt(_.get(error, ['response', 'headers', 'x-ratelimit-remaining'], 1)) const rateLimitReset = parseInt(_.get(error, ['response', 'headers', 'x-ratelimit-reset'], 1)) * 1000 diff --git a/tools/repos.js b/tools/repos.js index 1e309239..0f34d90b 100644 --- a/tools/repos.js +++ b/tools/repos.js @@ -80,16 +80,20 @@ const fetchGithubOrgs = async preferCache => { return { data: { url, repos, cached: true }, github_data, github_start_commit_data } } const orgName = url.split('/').pop() - const { description } = await GithubClient.request({ path: `orgs/${orgName}` }) - const params = { type: 'public', per_page: 100 } - const path = `orgs/${orgName}/repos` - const response = await GithubClient.request({ path, params }) - const repos = response.map(({ html_url, default_branch, size }) => { - if (size > 0) { - return { url: html_url, branch: default_branch, multiple: true } - } - }).filter(_ => _) - return { data: { url, repos }, github_data: { description } } + try { + const { description } = await GithubClient.request({ path: `orgs/${orgName}` }) + const params = { type: 'public', per_page: 100 } + const path = `orgs/${orgName}/repos` + const response = await GithubClient.request({ path, params }) + const repos = response.map(({ html_url, default_branch, size }) => { + if (size > 0) { + return { url: html_url, branch: default_branch, multiple: true } + } + }).filter(_ => _) + return { data: { url, repos }, github_data: { description } } + } catch(ex) { + console.info(`Failed to fetch org: ${orgName}`); + } }, { concurrency: 10 }) } module.exports.fetchGithubOrgs = fetchGithubOrgs;