- Updated queryWithPaging to make one request per second to avoid concurrency issues.\n- Created changeset

Signed-off-by: zcurrent <current.zachary@principal.com>
Signed-off-by: zcurrent <84637714+zcurrent@users.noreply.github.com>
This commit is contained in:
zcurrent
2023-04-20 22:01:53 +00:00
parent 76c5acd67e
commit 78bb674a71
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;
}
}