Harden async task flows and enhance analysis tooling
这个提交包含在:
@@ -10,6 +10,7 @@ function sleep(ms: number) {
|
||||
}
|
||||
|
||||
async function workOnce() {
|
||||
await db.failExhaustedBackgroundTasks();
|
||||
await db.requeueStaleBackgroundTasks(new Date(Date.now() - ENV.backgroundTaskStaleMs));
|
||||
|
||||
const task = await db.claimNextBackgroundTask(workerId);
|
||||
@@ -17,6 +18,12 @@ async function workOnce() {
|
||||
return false;
|
||||
}
|
||||
|
||||
const heartbeatTimer = setInterval(() => {
|
||||
void db.heartbeatBackgroundTask(task.id, workerId).catch((error) => {
|
||||
console.error(`[worker] heartbeat failed for ${task.id}:`, error);
|
||||
});
|
||||
}, ENV.backgroundTaskHeartbeatMs);
|
||||
|
||||
try {
|
||||
const result = await processBackgroundTask(task);
|
||||
if (result !== null) {
|
||||
@@ -27,6 +34,8 @@ async function workOnce() {
|
||||
await db.failBackgroundTask(task.id, message);
|
||||
await db.failVisionTestRun(task.id, message);
|
||||
console.error(`[worker] task ${task.id} failed:`, error);
|
||||
} finally {
|
||||
clearInterval(heartbeatTimer);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
在新工单中引用
屏蔽一个用户