Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

improved js response and test for getting partial_data

rafaelsideguide2b763d848bf5
diff --git a/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts b/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts
index c9db6a91e..7cb532ccb 100644
--- a/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts
+++ b/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts
@@ -99,8 +99,17 @@ describe('FirecrawlApp E2E Tests', () => {
expect(response).not.toBeNull();
expect(response.jobId).toBeDefined();
- await new Promise(resolve => setTimeout(resolve, 10000)); // wait for 10 seconds
- const statusResponse = await app.checkCrawlStatus(response.jobId);
+ let statusResponse = await app.checkCrawlStatus(response.jobId);
+ const maxChecks = 15;
+ let checks = 0;
+
+ while (statusResponse.status === 'active' && checks < maxChecks) {
+ await new Promise(resolve => setTimeout(resolve, 1000));
+ expect(statusResponse.partial_data).not.toBeNull();
+ statusResponse = await app.checkCrawlStatus(response.jobId);
+ checks++;
+ }
+
expect(statusResponse).not.toBeNull();
expect(statusResponse.status).toBe('completed');
expect(statusResponse.data.length).toBeGreaterThan(0);
diff --git a/apps/js-sdk/firecrawl/src/index.ts b/apps/js-sdk/firecrawl/src/index.ts
index 2a07f60d0..732955610 100644
--- a/apps/js-sdk/firecrawl/src/index.ts
+++ b/apps/js-sdk/firecrawl/src/index.ts
@@ -56,6 +56,7 @@ export interface JobStatusResponse {
status: string;
jobId?: string;
data?: any;
+ partial_data?: any,
error?: string;
}
@@ -226,7 +227,12 @@ export default class FirecrawlApp {
headers
);
if (response.status === 200) {
- return response.data;
+ return {
+ success: true,
+ status: response.data.status,
+ data: response.data.data,
+ partial_data: !response.data.data ? response.data.partial_data : undefined,
+ };
} else {
this.handleError(response, "check crawl status");
}