mirror of
https://github.com/firecrawl/firecrawl.git
synced 2026-03-13 08:21:20 +08:00
fix(api): await logRequest in scrape controllers to prevent FK violation
logRequest was fire-and-forget in v1/scrape and v2/scrape controllers, causing a race condition where the worker's logScrape could run before the requests row existed, violating the scrapes_request_id_fkey foreign key constraint. All other controllers (crawl, extract, etc.) already await logRequest correctly. Fixes API-NM Fixes API-EG
This commit is contained in:
@@ -67,7 +67,7 @@ export async function scrapeController(
|
||||
account: req.account,
|
||||
});
|
||||
|
||||
logRequest({
|
||||
await logRequest({
|
||||
id: jobId,
|
||||
kind: "scrape",
|
||||
api_version: "v1",
|
||||
@@ -77,9 +77,7 @@ export async function scrapeController(
|
||||
target_hint: req.body.url,
|
||||
zeroDataRetention: zeroDataRetention || false,
|
||||
api_key_id: req.acuc?.api_key_id ?? null,
|
||||
}).catch(err =>
|
||||
logger.warn("Background request log failed", { error: err, jobId }),
|
||||
);
|
||||
});
|
||||
|
||||
const origin = req.body.origin;
|
||||
const timeout = req.body.timeout;
|
||||
|
||||
@@ -126,7 +126,7 @@ export async function scrapeController(
|
||||
});
|
||||
|
||||
if (!agentRequestId) {
|
||||
logRequest({
|
||||
await logRequest({
|
||||
id: jobId,
|
||||
kind: "scrape",
|
||||
api_version: "v2",
|
||||
@@ -136,9 +136,7 @@ export async function scrapeController(
|
||||
target_hint: req.body.url,
|
||||
zeroDataRetention: zeroDataRetention || false,
|
||||
api_key_id: req.acuc?.api_key_id ?? null,
|
||||
}).catch(err =>
|
||||
logger.warn("Background request log failed", { error: err, jobId }),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
setSpanAttributes(span, {
|
||||
|
||||
Reference in New Issue
Block a user