Closed spyndutz closed 3 years ago
Found a workaround by adding unhandledRejection
process listener for every jobs
process.on('unhandledRejection', (err) => {
throw err;
});
This is likely due to some module that has been imported within the script throwing an unhandled rejection. This won't be caught by .catch()
chain. Check out this, which suggests that your method is the way to handle this.
Hello there, I'm currently using Node v14.16.0
Using the example here I've written my own job script.
Let's say we throw an error inside the Async IIFE like this:
jobs/example.js
the code above will result in the process printing to console these warning:
I know this shouldn't be Bree specific, it is more likely to be how NodeJS currently handle UnhandledPromiseRejection error which only prints error logs and doesn't actually terminate the node process (Which make the worker just hanging there as stale jobs).
The expected behavior is to terminate the process and send the thrown errors back to the Bree, and thus invoking my own custom
errorHandler
function that I have defined (Currently theerrorHandler
doesn't get invoked when the above behavior happens).Is there any way to make the worker use the
--unhandled-rejections=strict
without actually using it in our main application? Or is there any workaround to address this issue?