1
0
Fork 0

Pass worker result to success/failure handler instead of discarding it.

This commit is contained in:
Alan Plum 2014-08-22 13:16:34 +02:00
parent 2472622b7c
commit 83f47db07f
1 changed files with 4 additions and 2 deletions

View File

@ -72,7 +72,8 @@ exports.work = function (job) {
success = true,
callback = null,
now = Date.now(),
maxFailures;
maxFailures,
result;
if (!cfg) {
console.warn('Unknown job type for job ' + job._key + ':', job.type);
@ -87,7 +88,7 @@ exports.work = function (job) {
) || 0;
try {
cfg.execute(job.data, job._id);
result = cfg.execute(job.data, job._id);
} catch (executeErr) {
console.error('Job ' + job._key + ' failed:', executeErr);
job.failures.push(flatten(executeErr));
@ -120,6 +121,7 @@ exports.work = function (job) {
eval('(' + callback + ')(' + [
JSON.stringify(job._id),
JSON.stringify(job.data),
JSON.stringify(result),
JSON.stringify(job.failures)
].join(', ') + ')');
} catch (callbackErr) {