Nick: update extract in case there is an error

This commit is contained in:
Nicolas 2025-01-07 16:21:51 -03:00
parent eb254547e5
commit 11af214db1
3 changed files with 8 additions and 0 deletions

View File

@ -34,6 +34,7 @@ export async function extractStatusController(
success: true,
data: data,
status: extract.status,
error: extract?.error ?? undefined,
expiresAt: (await getExtractExpiry(req.params.jobId)).toISOString(),
});
}

View File

@ -7,6 +7,7 @@ export type StoredExtract = {
plan?: string;
createdAt: number;
status: "processing" | "completed" | "failed" | "cancelled";
error?: any;
};
export async function saveExtract(id: string, extract: StoredExtract) {

View File

@ -55,6 +55,7 @@ import { Document } from "../controllers/v1/types";
import { performExtraction } from "../lib/extract/extraction-service";
import { supabase_service } from "../services/supabase";
import { normalizeUrl, normalizeUrlOnlyHostname } from "../lib/canonical-url";
import { saveExtract, updateExtract } from "../lib/extract/extract-redis";
configDotenv();
@ -351,6 +352,11 @@ const processExtractJobInternal = async (token: string, job: Job & { id: string
// Move job to failed state in Redis
await job.moveToFailed(error, token, false);
await updateExtract(job.data.extractId, {
status: "failed",
error: error.error ?? error ?? "Unknown error, please contact help@firecrawl.dev. Extract id: " + job.data.extractId,
});
// throw error;
} finally {