Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firecrawl-cli",
"version": "1.19.18",
"version": "1.19.19",
"description": "Command-line interface for Firecrawl. Scrape, crawl, and extract data from any website directly from your terminal.",
"main": "dist/index.js",
"bin": {
Expand Down
13 changes: 8 additions & 5 deletions src/__tests__/commands/crawl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ describe('executeCrawl', () => {
expect(mockClient.crawl).toHaveBeenCalledWith(
'https://example.com',
expect.objectContaining({
pollInterval: 5000, // Default poll interval
pollInterval: 5, // SDK waiter expects seconds
})
);
expect(result).toEqual({
Expand Down Expand Up @@ -371,7 +371,7 @@ describe('executeCrawl', () => {
expect(mockClient.crawl).toHaveBeenCalledWith(
'https://example.com',
expect.objectContaining({
pollInterval: 10000, // Converted to milliseconds
pollInterval: 10,
})
);
});
Expand All @@ -395,7 +395,7 @@ describe('executeCrawl', () => {
expect(mockClient.crawl).toHaveBeenCalledWith(
'https://example.com',
expect.objectContaining({
timeout: 300000, // Converted to milliseconds
timeout: 300,
})
);
});
Expand All @@ -422,8 +422,8 @@ describe('executeCrawl', () => {
expect(mockClient.crawl).toHaveBeenCalledWith(
'https://example.com',
expect.objectContaining({
pollInterval: 5000,
timeout: 600000,
pollInterval: 5,
timeout: 600,
limit: 50,
maxDiscoveryDepth: 2,
})
Expand Down Expand Up @@ -488,6 +488,9 @@ describe('executeCrawl', () => {
const result = await crawlPromise;

expect(mockClient.startCrawl).toHaveBeenCalledTimes(1);
const [, startOptions] = mockClient.startCrawl.mock.calls[0];
expect(startOptions).not.toHaveProperty('pollInterval');
expect(startOptions).not.toHaveProperty('timeout');
expect(mockClient.getCrawlStatus).toHaveBeenCalledTimes(2);
expect(result.success).toBe(true);
if (result.success && 'data' in result) {
Expand Down
23 changes: 10 additions & 13 deletions src/commands/crawl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,10 @@ export async function executeCrawl(

// If wait mode, use the convenience crawl method with polling
if (wait) {
// Set polling options
if (pollInterval !== undefined) {
crawlOptions.pollInterval = pollInterval * 1000; // Convert to milliseconds
} else {
// Default poll interval: 5 seconds
crawlOptions.pollInterval = 5000;
}
if (timeout !== undefined) {
crawlOptions.timeout = timeout * 1000; // Convert to milliseconds
}
const waiterOptions = {
pollInterval: pollInterval ?? 5,
...(timeout !== undefined ? { timeout } : {}),
};

// Show progress if requested - use custom polling for better UX
if (options.progress) {
Expand All @@ -153,9 +147,9 @@ export async function executeCrawl(
process.stderr.write(`Job ID: ${jobId}\n`);

// Poll for status with progress updates
const pollMs = crawlOptions.pollInterval || 5000;
const pollMs = waiterOptions.pollInterval * 1000;
const startTime = Date.now();
const timeoutMs = timeout ? timeout * 1000 : undefined;
const timeoutMs = timeout !== undefined ? timeout * 1000 : undefined;

while (true) {
await new Promise((resolve) => setTimeout(resolve, pollMs));
Expand Down Expand Up @@ -190,7 +184,10 @@ export async function executeCrawl(
}
} else {
// Use SDK's built-in polling (no progress display)
const crawlJob = await app.crawl(urlOrJobId, crawlOptions);
const crawlJob = await app.crawl(urlOrJobId, {
...crawlOptions,
...waiterOptions,
});
return {
success: true,
data: crawlJob,
Expand Down
Loading