diff --git a/src/tasks.js b/src/tasks.js index 8bef7a82c..d4446f328 100644 --- a/src/tasks.js +++ b/src/tasks.js @@ -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) {