The example given for the error event is as follows:
const queue = new PQueue({concurrency: 2});
queue.on('error', error => {
console.error(error);
});
queue.add(() => Promise.reject(new Error('error')));
But as noted here:
If your items can potentially throw an exception, you must handle those errors from the returned Promise or they may be reported as an unhandled Promise rejection and potentially cause your process to exit immediately.
The error
event handler example above doesn't follow this guidance, and throws an exception that isn't handled, crashing the node app, so that the event handler is sadly never called.
So we must add an error handler on the item to catch the error... but in which case what use does the error
event handler have?
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too