-
Notifications
You must be signed in to change notification settings - Fork 48
Fix: CLI crawl --wait polling interval bug (double ms conversion)
#100
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
+120
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); | ||
|
|
||
|
|
@@ -145,7 +151,7 @@ export async function executeCrawl( | |
| } | ||
|
|
||
| // Check timeout | ||
| if (timeoutMs && Date.now() - startTime > timeoutMs) { | ||
| if (timeoutMs !== undefined && Date.now() - startTime > timeoutMs) { | ||
| process.stderr.write('\n'); | ||
| return { | ||
| success: false, | ||
|
|
||
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.
crawlOptionsis typed asPartial<CrawlOptions> & Record<string, any>, but this object is the SDK parameter bag (it includes fields likeintegrationandmaxDiscoveryDepththat are not part ofCrawlOptions, and omits CLI-only fields that are inCrawlOptions). This type can be misleading and doesn’t provide useful safety. Consider defining a dedicated SDK params type (similar toagentParamsinsrc/commands/agent.ts:196-208) or using a plainRecord<string, any>here.