assume code 1 task 9 is oom

Fixes #750
This commit is contained in:
Girish Ramakrishnan
2020-12-21 18:06:20 -08:00
parent 33fb093aeb
commit 88f24afae6

View File

@@ -161,10 +161,18 @@ function startTask(id, options, callback) {
get(id, function (getError, task) {
let taskError;
if (!getError && task.percent !== 100) { // taskworker crashed or was killed by us
taskError = {
message: code === 0 ? `Task ${id} ${timedOut ? 'timed out' : 'stopped'}` : `Task ${id} crashed with code ${code} and signal ${signal}`,
code: code === 0 ? (timedOut ? exports.ETIMEOUT : exports.ESTOPPED) : exports.ECRASHED
};
if (code === 0) {
taskError = {
message: `Task ${id} ${timedOut ? 'timed out' : 'stopped'}` ,
code: timedOut ? exports.ETIMEOUT : exports.ESTOPPED
};
} else { // task crashed
taskError = {
message: signal === 9 ? `Task ${id} crashed as it ran out of memory` : `Task ${id} crashed with code ${code} and signal ${signal}`,
code: exports.ECRASHED
};
}
// note that despite the update() here, we should handle the case where the box code was restarted and never got taskworker exit
setCompleted(id, { error: taskError }, NOOP_CALLBACK);
} else if (!getError && task.error) {