Automattic / Automattic/kue

Failed jobs should be able to return an object in the job callback

Open
#635 6 comments 1 reaction 0 assignees View on GitHub
needs pull request Optimization
Dominant language
JavaScript
Stars
9.4k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

When failing a job by passing a parameter into the first argument of the `done()` callback, this object usually gets converted to a string. It would offer more flexibility to the pass back the object without calling `toString()`.

Here is the code that converts the error parameter into a string
https://github.com/Automattic/kue/blob/master/lib/queue/worker.js#L126

Passing an object on success does not get converted, see https://github.com/Automattic/kue/blob/master/lib/queue/worker.js#L193

As a workaround, one can fail a jobs like this in order to get an object passed back

```
done({message: {foo:'bar'}});
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in lib/queue/worker.js at line 126, where the failed-job callback parameter is converted to a string, and compare it with the success path around line 193. Verify the behavior using the existing worker or job callback tests, and consider the issue done when an object passed to done() on failure is returned without being stringified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.