Skip to content

Commit

Permalink
Sleep between notion cursors (#2008)
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanierh authored Oct 9, 2023
1 parent c82197a commit 9db4f12
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion connectors/src/connectors/notion/lib/notion_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,8 @@ export async function* iteratePaginatedAPIWithRetries<
retry: { retries: number; backoffFactor: number } = {
retries: 5,
backoffFactor: 2,
}
},
sleepMs = 1000
): AsyncIterableIterator<Item> {
let nextCursor: string | null | undefined = firstPageArgs.start_cursor;
let resultPageIdx = 0;
Expand Down Expand Up @@ -1321,5 +1322,9 @@ export async function* iteratePaginatedAPIWithRetries<
yield* response.results;
nextCursor = response.next_cursor;
resultPageIdx += 1;

if (nextCursor && sleepMs) {
await new Promise((resolve) => setTimeout(resolve, sleepMs));
}
} while (nextCursor);
}

0 comments on commit 9db4f12

Please sign in to comment.