diff --git a/lib/github-api.js b/lib/github-api.js index 10be573..8f1b2cc 100644 --- a/lib/github-api.js +++ b/lib/github-api.js @@ -48,7 +48,9 @@ async function checkRateLimit() { // Wait for rate limit to reset using polling async function waitForRateLimitReset(targetResetTime) { const POLL_INTERVAL = 60000; // 60 seconds - const MIN_REMAINING_TO_CONTINUE = 100; // Need at least 100 requests available + // In CI: use low threshold for incremental progress within timeout constraints + // Locally: use high threshold for better user experience (fewer interruptions) + const MIN_REMAINING_TO_CONTINUE = process.env.CI === 'true' ? 100 : 4500; const MAX_POLLS = 120; // Max 120 polls = 2 hours const estimatedWaitMinutes = Math.ceil(Math.max(0, targetResetTime - Date.now()) / 60000); @@ -96,16 +98,16 @@ async function waitForRateLimitReset(targetResetTime) { // Check if we have enough requests to continue if (status.remaining >= MIN_REMAINING_TO_CONTINUE) { console.log(chalk.green(`\n✓ Rate limit reset! ${status.remaining}/${status.limit} requests available.`)); - console.log(chalk.green(` Resuming indexing... (will continue from last successful state)`)); + console.log(chalk.green(` Resuming indexing...`)); lastRateLimitRecoveryTime = Date.now(); // Mark recovery time return; } - // Still rate limited + // Still waiting for threshold if (status.remaining === 0) { - console.log(chalk.yellow(` Still rate limited (0 remaining). Will check again in 60s.`)); + console.log(chalk.yellow(` Still rate limited (0 remaining). Waiting for reset...`)); } else { - console.log(chalk.yellow(` Only ${status.remaining} requests remaining (need ${MIN_REMAINING_TO_CONTINUE}). Will check again in 60s.`)); + console.log(chalk.yellow(` Only ${status.remaining}/${status.limit} available (need ${MIN_REMAINING_TO_CONTINUE}+). Will check again in 60s.`)); } } }