OptimalBits / bull

Premium Queue package for handling distributed jobs and messages in NodeJS.
Other
15.58k stars 1.43k forks source link

Empty object errors? #1326

Closed derekchiang closed 3 years ago

derekchiang commented 5 years ago

Description

I have an event listener that looks like the following:

myQueue.on('error', (err) => {
  console.error(err)
})

However, lately I'm getting a lot of error messages where it simply prints the empty object {}.

Does this suggest that something in my code is throwing an empty object? Or is this a bug in bull?

Bull version

3.9.1

manast commented 5 years ago

Impossible to say actually without some kind of code that reproduces the issue, but If I have to guess I would say that you are throwing an empty object as error somewhere.

humphd commented 4 years ago

I'm hitting something similar with the failed event.

My code is doing this. First, my processor function looks like this:

async process function(job) {
  const { url } = job.data;
  try {
    const posts = await feedparser(url);
    return await Promise.all(posts.map(processPost));
  } catch (err) {
    const message = `Unable to process feed ${url} for job ${job.id}`;
    logger.error({ err }, message);
    throw new Error(message);
  }
};

I'm catching and constructing a new Error object, because I originally wondered if the err wasn't a real Error and that was the problem. It doesn't seem to be.

Here's my error event handler:

queue.on('failed', (job, err) => {
  log.error(`Job ${job.id} failed:`, err);
});

And a sample of my error logs for a failed job, first showing the actual error happening in the processor, and then the failed event I get:

[ 2019-12-04 09:38:21.587 ] ERROR (43628 on brightness.local): Unable to process feed http://processingjs.org/blog/?feed=rss2 for job 720
    err: {
      "type": "Error",
      "message": "Not a feed",
      "stack":
          Error: Not a feed
              at FeedParser.handleEnd (/Users/humphd/repos/telescope/node_modules/feedparser/lib/feedparser/index.js:120:13)
              at SAXStream.emit (events.js:210:5)
              at SAXParser.SAXStream._parser.onend (/Users/humphd/repos/telescope/node_modules/sax/lib/sax.js:190:10)
              at emit (/Users/humphd/repos/telescope/node_modules/sax/lib/sax.js:624:35)
              at end (/Users/humphd/repos/telescope/node_modules/sax/lib/sax.js:667:5)
              at SAXParser.end (/Users/humphd/repos/telescope/node_modules/sax/lib/sax.js:154:24)
              at SAXStream.end (/Users/humphd/repos/telescope/node_modules/sax/lib/sax.js:248:18)
              at FeedParser._flush (/Users/humphd/repos/telescope/node_modules/feedparser/lib/feedparser/index.js:1128:17)
              at FeedParser.prefinish (/Users/humphd/repos/telescope/node_modules/readable-stream/lib/_stream_transform.js:138:10)
              at FeedParser.emit (events.js:210:5)
    }
[ 2019-12-04 09:38:21.588 ] ERROR (43628 on brightness.local): Job 720 failed: {}
    module: "queue:feed-queue"
humphd commented 4 years ago

Just saw a failed that did have some info:

[ 2019-12-04 14:36:00.989 ] ERROR (45000 on brightness.local): Job 2548 failed: {"errno":"ENETUNREACH","code":"ENETUNREACH","syscall":"connect","address":"206.248.171.116","port":80}
...
[ 2019-12-04 14:36:04.969 ] ERROR (45000 on brightness.local): Job 2560 failed: {"code":"CERT_HAS_EXPIRED"}

So some error objects get through. Not sure why all don't.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.