fix: move to completed in one place

This commit is contained in:
Gergo Moricz 2024-08-07 18:49:22 +02:00
parent 457c082ba1
commit 191dfbd9ca
2 changed files with 16 additions and 16 deletions

View File

@ -141,21 +141,21 @@ const saveJob = async (job: Job, result: any, token: string, mode: string) => {
.eq("job_id", job.id);
if (error) throw new Error(error.message);
try {
if (mode === "crawl") {
await job.moveToCompleted(null, token, false);
} else {
await job.moveToCompleted(result, token, false);
}
} catch (error) {
// I think the job won't exist here anymore
}
} else {
try {
await job.moveToCompleted(result, token, false);
} catch (error) {
// I think the job won't exist here anymore
}
// try {
// if (mode === "crawl") {
// await job.moveToCompleted(null, token, false);
// } else {
// await job.moveToCompleted(result, token, false);
// }
// } catch (error) {
// // I think the job won't exist here anymore
// }
// } else {
// try {
// await job.moveToCompleted(result, token, false);
// } catch (error) {
// // I think the job won't exist here anymore
// }
}
ScrapeEvents.logJobEvent(job, "completed");
} catch (error) {

View File

@ -51,7 +51,7 @@ const processJobInternal = async (token: string, job: Job) => {
try {
const result = await processJob(job, token);
const jobState = await job.getState();
if(jobState !== "completed" && jobState !== "failed"){
if (jobState !== "completed" && jobState !== "failed") {
try{
await job.moveToCompleted(result.docs, token, false); //3rd arg fetchNext
}catch(e){