-
Notifications
You must be signed in to change notification settings - Fork 45
Fix: double conversion of pollInterval and timeout in --wait mode #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,7 @@ export async function executeCrawl( | |
| } | ||
|
|
||
| // Build crawl options | ||
| const crawlOptions: any = { | ||
| const crawlOptions: Partial<CrawlOptions> & Record<string, any> = { | ||
| 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; | ||
|
Comment on lines
+126
to
+129
|
||
|
|
||
| while (true) { | ||
| await new Promise((resolve) => setTimeout(resolve, pollMs)); | ||
| await new Promise<void>((resolve) => setTimeout(resolve, pollMs)); | ||
|
|
||
| const status = await app.getCrawlStatus(jobId); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change switches
pollInterval/timeoutpassed to the SDK from milliseconds to seconds (defaultpollIntervalis now5, not5000). The existing unit tests forexecuteCrawlcurrently assert millisecond values (e.g.,pollInterval: 5000,timeout: 300000) and will need to be updated to match the new units so CI stays green.