You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
@drmrbrewer just ran into the same thing. I ended up adding an empty catch to the queue.add() in order to have the event handler take care of the error handling:
constqueue=newPQueue({concurrency: 2});queue.on('error',error=>{console.error(error);});queue.add(()=>Promise.reject(newError('error'))).catch(()=>{/* handled in event callback */});
The example given for the error event is as follows:
But as noted here:
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?The text was updated successfully, but these errors were encountered: