mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-05 10:30:43 +08:00
Merge branch 'main' into v1-webscraper
This commit is contained in:
commit
1054a1397b
@ -61,6 +61,12 @@ export async function scrapeHelper(
|
||||
error: "Request timed out",
|
||||
returnCode: 408,
|
||||
}
|
||||
} else if (typeof e === "string" && (e.includes("Error generating completions: ") || e.includes("Invalid schema for function"))) {
|
||||
return {
|
||||
success: false,
|
||||
error: e,
|
||||
returnCode: 500,
|
||||
};
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
@ -211,6 +217,6 @@ export async function scrapeController(req: Request, res: Response) {
|
||||
} catch (error) {
|
||||
Sentry.captureException(error);
|
||||
Logger.error(error);
|
||||
return res.status(500).json({ error: error.message });
|
||||
return res.status(500).json({ error: typeof error === "string" ? error : (error?.message ?? "Internal Server Error") });
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,15 @@ export function waitForJob(jobId: string, timeout: number) {
|
||||
if (Date.now() >= start + timeout) {
|
||||
clearInterval(int);
|
||||
reject(new Error("Job wait "));
|
||||
} else if (await getScrapeQueue().getJobState(jobId) === "completed") {
|
||||
clearInterval(int);
|
||||
resolve((await getScrapeQueue().getJob(jobId)).returnvalue);
|
||||
} else {
|
||||
const state = await getScrapeQueue().getJobState(jobId);
|
||||
if (state === "completed") {
|
||||
clearInterval(int);
|
||||
resolve((await getScrapeQueue().getJob(jobId)).returnvalue);
|
||||
} else if (state === "failed") {
|
||||
clearInterval(int);
|
||||
reject((await getScrapeQueue().getJob(jobId)).failedReason);
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user