tasks: distinguish runtime crash vs task error in worker

This commit is contained in:
Girish Ramakrishnan
2025-07-18 19:33:34 +02:00
parent 5d8871a044
commit 48559d3358
3 changed files with 25 additions and 19 deletions

View File

@@ -83,11 +83,11 @@ function postProcess(task) {
// result.pending - task is scheduled to run at some point
// result.completed - task finished and exit/crash was cleanly collected. internal flag.
task.running = !!gTasks[task.id]; // running means actively running
task.active = task.running || task.pending; // active mean task is 'done' or not. at this point, clients can stop polling this task.
task.active = task.running || task.pending; // active mean task is 'done'. at this point, clients can stop polling this task.
task.success = task.completed && !task.error; // if task has completed without an error
// the error in db will be empty if we didn't get a chance to handle task exit
if (!task.active && !task.completed && !task.error) {
// the error in db will be empty if task is done but the completed flag is not set
if (!task.active && !task.completed) {
task.error = { message: 'Task was stopped because the server restarted or crashed', code: exports.ECRASHED };
}