From ea989a2f35e35335340d411468813aa78b2416a9 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/github/repository.ts b/src/github/repository.ts index dee1f88..fe2f471 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)}`); @@ -92,13 +102,21 @@ export class RepositoryApi { `Extracting all issue information from ${this.repo.owner}/${this.repo.repo}`, ); do { - const query: IssueList = await this.api.graphql( + let query:IssueList; + try{ + query = await this.api.graphql( ISSUE_LIST_QUERY, { cursor, ...this.repo, }, ); + }catch(e){ + this.logger.error(e as Error); + this.logger.warn(JSON.stringify(e)); + + throw e; + } const totalPages = Math.floor(query.repository.issues.totalCount / 100) + 1; this.logger.info(`Querying page ${++currentPage}/${totalPages}`);