From 52dc23068768f1daac35f34579cccc672ae3f39d Mon Sep 17 00:00:00 2001 From: Javier Bullrich Date: Mon, 15 Apr 2024 13:58:15 +0200 Subject: [PATCH] UNDO THIS - limit experiment --- src/github/repository.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/github/repository.ts b/src/github/repository.ts index dee1f88..d138224 100644 --- a/src/github/repository.ts +++ b/src/github/repository.ts @@ -51,7 +51,9 @@ export class RepositoryApi { `Extracting all PR information from ${this.repo.owner}/${this.repo.repo}`, ); do { - const query: PullRequestList = await this.api.graphql( + let query: PullRequestList + try{ + query = await this.api.graphql( PULL_REQUEST_LIST_QUERY, { cursor, @@ -59,6 +61,12 @@ export class RepositoryApi { }, ); this.logger.info(`Rate limits are ${JSON.stringify(query.rateLimit)}`); + }catch(e){ + this.logger.error(e as Error); + this.logger.warn(JSON.stringify(e)); + + throw e; + } const totalPages = Math.floor(query.repository.pullRequests.totalCount / 100) + 1; this.logger.info(`Querying page ${++currentPage}/${totalPages}`); @@ -66,10 +74,12 @@ export class RepositoryApi { prs.push(...nodes); hasNextPage = pageInfo.hasNextPage; cursor = pageInfo.endCursor; + /* if(currentPage % 5 === 0){ this.logger.debug("Pausing for one minute to not hit secondary limits") await new Promise(resolve => setTimeout(() => resolve(), 60_000)); } + */ if (query.rateLimit.remaining < 300) { const {resetAt} = query.rateLimit; this.logger.info(`About to reach limit. Limit resets at ${resetAt}. Waiting for ${secondsToTime(resetAt)}`);