tasks: distinguish runtime crash vs task error in worker
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user