Nick: update extract in case there is an error
This commit is contained in:
@@ -34,6 +34,7 @@ export async function extractStatusController(
|
|||||||
success: true,
|
success: true,
|
||||||
data: data,
|
data: data,
|
||||||
status: extract.status,
|
status: extract.status,
|
||||||
|
error: extract?.error ?? undefined,
|
||||||
expiresAt: (await getExtractExpiry(req.params.jobId)).toISOString(),
|
expiresAt: (await getExtractExpiry(req.params.jobId)).toISOString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export type StoredExtract = {
|
|||||||
plan?: string;
|
plan?: string;
|
||||||
createdAt: number;
|
createdAt: number;
|
||||||
status: "processing" | "completed" | "failed" | "cancelled";
|
status: "processing" | "completed" | "failed" | "cancelled";
|
||||||
|
error?: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function saveExtract(id: string, extract: StoredExtract) {
|
export async function saveExtract(id: string, extract: StoredExtract) {
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import { Document } from "../controllers/v1/types";
|
|||||||
import { performExtraction } from "../lib/extract/extraction-service";
|
import { performExtraction } from "../lib/extract/extraction-service";
|
||||||
import { supabase_service } from "../services/supabase";
|
import { supabase_service } from "../services/supabase";
|
||||||
import { normalizeUrl, normalizeUrlOnlyHostname } from "../lib/canonical-url";
|
import { normalizeUrl, normalizeUrlOnlyHostname } from "../lib/canonical-url";
|
||||||
|
import { saveExtract, updateExtract } from "../lib/extract/extract-redis";
|
||||||
|
|
||||||
configDotenv();
|
configDotenv();
|
||||||
|
|
||||||
@@ -351,6 +352,11 @@ const processExtractJobInternal = async (token: string, job: Job & { id: string
|
|||||||
|
|
||||||
// Move job to failed state in Redis
|
// Move job to failed state in Redis
|
||||||
await job.moveToFailed(error, token, false);
|
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;
|
// throw error;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user