mcollina / fastq

Fast, in memory work queue
ISC License
943 stars 47 forks source link

docs: fix unhandledRejection statement #85

Closed Eomm closed 3 months ago

Eomm commented 3 months ago

The statement seems not correct (node v20.x):

This promise could be ignored as it will not lead to a 'unhandledRejection'.

const queue = require('fastq').promise(worker, 1);

async function worker (arg) {
  throw new Error('app error');
}

process.on('unhandledRejection', (err) => {
  console.error({ unhandledRejection: err });
});

async function run () {
  const result = await queue.push(42);
  console.log('the result is', result);
}

run();

Output:

{
  unhandledRejection: Error: app error....
}
mcollina commented 3 months ago

Have you tried not awaiting it at all?

Eomm commented 3 months ago

Ok, it was my run that triggers the unhandled exception 👍🏼