Add error code for timeout

This commit is contained in:
Girish Ramakrishnan
2019-10-11 19:30:21 -07:00
parent 43fd207164
commit be5290c5ca

View File

@@ -30,6 +30,7 @@ exports = module.exports = {
// error codes
ESTOPPED: 'stopped',
ECRASHED: 'crashed',
ETIMEOUT: 'timeout',
// testing
_TASK_IDENTITY: '_identity',
@@ -186,7 +187,7 @@ function startTask(taskId, options, callback) {
if (!error && task.percent !== 100) { // task crashed or was killed by us
taskError = {
message: code === 0 ? `Task ${taskId} ${timedOut ? 'timed out' : 'stopped'}` : `Task ${taskId} crashed with code ${code} and signal ${signal}`,
code: code === 0 ? exports.ESTOPPED : exports.ECRASHED
code: code === 0 ? (timedOut ? exports.ETIMEOUT : exports.ESTOPPED) : 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(taskId, { error: taskError }, NOOP_CALLBACK);