mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-11 21:09:00 +08:00
fix(js-sdk/crawl,batch-scrape): retry status call if it returns an error up to 3 times (#1343)
This commit is contained in:
parent
905885abf9
commit
ca93ba6c6d
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mendable/firecrawl-js",
|
"name": "@mendable/firecrawl-js",
|
||||||
"version": "1.19.1",
|
"version": "1.19.2",
|
||||||
"description": "JavaScript SDK for Firecrawl API",
|
"description": "JavaScript SDK for Firecrawl API",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
@ -1332,12 +1332,14 @@ export default class FirecrawlApp {
|
|||||||
checkInterval: number
|
checkInterval: number
|
||||||
): Promise<CrawlStatusResponse | ErrorResponse> {
|
): Promise<CrawlStatusResponse | ErrorResponse> {
|
||||||
try {
|
try {
|
||||||
|
let failedTries = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
let statusResponse: AxiosResponse = await this.getRequest(
|
let statusResponse: AxiosResponse = await this.getRequest(
|
||||||
`${this.apiUrl}/v1/crawl/${id}`,
|
`${this.apiUrl}/v1/crawl/${id}`,
|
||||||
headers
|
headers
|
||||||
);
|
);
|
||||||
if (statusResponse.status === 200) {
|
if (statusResponse.status === 200) {
|
||||||
|
failedTries = 0;
|
||||||
let statusData = statusResponse.data;
|
let statusData = statusResponse.data;
|
||||||
if (statusData.status === "completed") {
|
if (statusData.status === "completed") {
|
||||||
if ("data" in statusData) {
|
if ("data" in statusData) {
|
||||||
@ -1369,7 +1371,10 @@ export default class FirecrawlApp {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.handleError(statusResponse, "check crawl status");
|
failedTries++;
|
||||||
|
if (failedTries >= 3) {
|
||||||
|
this.handleError(statusResponse, "check crawl status");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user