Merge pull request #17478 from zcurrent/master

Avoid secondary rate limits during GitHub Discovery
This commit is contained in:
Fredrik Adelöw
2023-04-25 14:04:11 +02:00
committed by GitHub
2 changed files with 7 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-github': patch
---
Fixed bug in queryWithPaging that caused secondary rate limit errors in GitHub with organizations having more than 1000 repositories. This change makes one request per second to avoid concurrency issues.
@@ -545,6 +545,7 @@ export async function queryWithPaging<
variables: Variables,
): Promise<OutputType[]> {
const result: OutputType[] = [];
const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
let cursor: string | undefined = undefined;
for (let j = 0; j < 1000 /* just for sanity */; ++j) {
@@ -573,6 +574,7 @@ export async function queryWithPaging<
if (!conn.pageInfo.hasNextPage) {
break;
} else {
await sleep(1000);
cursor = conn.pageInfo.endCursor;
}
}