From 169d9e2ca73de1ee4d3e8e1b7aed7f03597e58f8 Mon Sep 17 00:00:00 2001 From: shiva-manu Date: Thu, 16 Apr 2026 14:39:51 +0530 Subject: [PATCH] fix(cli): prevent double conversion of pollInterval and timeout in --wait mode --- src/commands/crawl.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/commands/crawl.ts b/src/commands/crawl.ts index ab00bea61..f0867ad79 100644 --- a/src/commands/crawl.ts +++ b/src/commands/crawl.ts @@ -57,7 +57,7 @@ export async function executeCrawl( } // Build crawl options - const crawlOptions: any = { + const crawlOptions: Partial & Record = { integration: 'cli', }; @@ -97,15 +97,15 @@ export async function executeCrawl( // If wait mode, use the convenience crawl method with polling if (wait) { - // Set polling options + // Set polling options (SDK expects seconds, not ms) if (pollInterval !== undefined) { - crawlOptions.pollInterval = pollInterval * 1000; // Convert to milliseconds + crawlOptions.pollInterval = pollInterval; // seconds } else { // Default poll interval: 5 seconds - crawlOptions.pollInterval = 5000; + crawlOptions.pollInterval = 5; } if (timeout !== undefined) { - crawlOptions.timeout = timeout * 1000; // Convert to milliseconds + crawlOptions.timeout = timeout; // seconds } // Show progress if requested - use custom polling for better UX @@ -117,13 +117,19 @@ export async function executeCrawl( process.stderr.write(`Crawling ${urlOrJobId}...\n`); process.stderr.write(`Job ID: ${jobId}\n`); - // Poll for status with progress updates - const pollMs = crawlOptions.pollInterval || 5000; + // Converts seconds -> ms Only here + const pollMs = + crawlOptions.pollInterval !== undefined + ? crawlOptions.pollInterval * 1000 + : 5000; const startTime = Date.now(); - const timeoutMs = timeout ? timeout * 1000 : undefined; + const timeoutMs = + crawlOptions.timeout !== undefined + ? crawlOptions.timeout * 1000 + : undefined; while (true) { - await new Promise((resolve) => setTimeout(resolve, pollMs)); + await new Promise((resolve) => setTimeout(resolve, pollMs)); const status = await app.getCrawlStatus(jobId);