Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #1077
Closed
Open
Issue created Oct 05, 2018 by Administrator@rootContributor

Bull passing error.cause to failed handlers

Created by: gabegorelick

Description

When failing a job with an Error, Bull attempts to grab the error's cause:

https://github.com/OptimalBits/bull/blob/cf2c6883fc2d861397bd59df7186b730800655e0/lib/queue.js#L1026-L1027

However, there's no guarantee cause will be an instance of Error. In fact, if you pass a VError, cause will be a function that returns the cause. This causes (no pun intended) Bull to pass incorrect values to any failed handler.

I'm also not sure why Bull would want to return the cause and obscure the higher level error in the first place. If I'm passing a wrapped Error as the failure, surely that means I want that error to be returned, and not the lower level error. EDIT: there's a handy test case that explains the rationale: https://github.com/OptimalBits/bull/blob/cf2c6883fc2d861397bd59df7186b730800655e0/test/test_queue.js#L1213

Minimal, Working Test code to reproduce the issue.

const Queue = require('bull');
const VError = require('verror');

const queue = new Queue('foo');
queue.process('job', (job, callback) => {
    callback(new VError(new Error('root cause'), 'wrapper message'));
});
queue.on('failed', (job, err) => {
    console.log(err.stack); // prints `undefined`
    process.exit();
});

queue.add('job', {});

Bull version

3.4.8

Assignee
Assign to
Time tracking