update: error handling in bulk fetch

This commit is contained in:
alikia2x (寒寒) 2025-03-27 03:44:41 +08:00
parent 189bb294cb
commit c12379134c
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6

View File

@ -249,13 +249,28 @@ export const takeBulkSnapshotForVideosWorker = async (job: Job) => {
logger.log(`Taken snapshot for video ${aid} in bulk.`, "net", "fn:takeBulkSnapshotForVideosWorker");
}
await bulkSetSnapshotStatus(client, ids, "completed");
for (const aid of aidsToFetch) {
const interval = await getRegularSnapshotInterval(client, aid);
logger.log(`Scheduled regular snapshot for aid ${aid} in ${interval} hours.`, "mq");
await scheduleSnapshot(client, aid, "normal", Date.now() + interval * HOUR);
}
return `DONE`;
} finally {
} catch (e) {
if (e instanceof NetSchedulerError && e.code === "NO_PROXY_AVAILABLE") {
logger.warn(
`No available proxy for aid ${job.data.aid}.`,
"mq",
"fn:takeSnapshotForVideoWorker",
);
await bulkSetSnapshotStatus(client, ids, "completed");
await bulkScheduleSnapshot(client, aidsToFetch, "normal", Date.now() + 2 * MINUTE);
return;
}
logger.error(e as Error, "mq", "fn:takeSnapshotForVideoWorker");
await bulkSetSnapshotStatus(client, ids, "failed");
}
finally {
client.release();
}
};