always emit job failure event

This commit is contained in:
2016-07-12 11:14:58 -07:00
parent 25878c0b33
commit 8e8609eede

View File

@@ -117,6 +117,12 @@ export default class Job extends events.EventEmitter {
output: docOutput output: docOutput
}; };
this.emit(constants.EVENT_WORKER_JOB_FAIL, {
job: formatJobObject(job),
worker: this.toJSON(),
output: docOutput,
});
return this.client.update({ return this.client.update({
index: job._index, index: job._index,
type: job._type, type: job._type,
@@ -124,16 +130,7 @@ export default class Job extends events.EventEmitter {
version: job._version, version: job._version,
body: { doc } body: { doc }
}) })
.then(() => { .then(() => true)
const eventOutput = {
job: formatJobObject(job),
worker: this.toJSON(),
output: docOutput,
};
this.emit(constants.EVENT_WORKER_JOB_FAIL, eventOutput);
return true;
})
.catch((err) => { .catch((err) => {
if (err.statusCode === 409) return true; if (err.statusCode === 409) return true;
this.debug(`_failJob failed to update job ${job._id}`, err); this.debug(`_failJob failed to update job ${job._id}`, err);