fix(github): paginateSearchWithRetry triggers 403 rate limit and disc…#34
fix(github): paginateSearchWithRetry triggers 403 rate limit and disc…#34Fei-Good wants to merge 1 commit into
Conversation
…ards already-fetched data on retry
jadeproheshan
left a comment
There was a problem hiding this comment.
Moving the [items] array out of the loop and handling the 403 fallback perfectly fixes the memory clear bug during rate limits. Simple and effective.
While reviewing this, I realized we can make this even stronger. Since the GitHub Search API quota is strictly 30 requests/min, we easily hit the wall. Instead of safely failing, we can leverage the Octokit paginator to resume from where we left off (resumable pagination).
Octokit's actually accepts a page parameter. We just need to track the last successful page and pass it on the next loop, like this:
let currentPage = 1; // Track our progress
while (attempt < MAX_PAGINATION_RETRIES) {
try {
for await (const response of this.octokit.paginate.iterator(
this.octokit.rest.search.issuesAndPullRequests,
{
q: searchQuery,
sort: 'updated',
order: 'desc',
per_page: SEARCH_RESULTS_PER_PAGE,
page: currentPage, // Resume from the dropped page
},
)) {
// Handle data...
currentPage++; // Increment heavily
if (currentPage >= MAX_SEARCH_PAGES) break;
}Since these two features perfectly complement each other (your 403 handling + resuming pagination), I think we should fix them all here.
Would you mind if I push my resume logic directly to your branch so we can get it all merged at once?
|
no problem |
jadeproheshan
left a comment
There was a problem hiding this comment.
Because i dont have write-access to your pr,so i open a new pr #35 which combines our work.You can go ahead and review my code in that Pr and close this pr.Also, we can think through the discussion points together there.
fix #33
itemsandpagesFetchedoutside thewhileloop to prevent data loss during retriesMAX_SEARCH_PAGES = 8, with a maximum of 16 Search API requests (2 label groups), leaving 14 quota units remainingX-RateLimit-Resethave been corrected (removing the incorrectwaitMs < 60_000upper limit).