If the input
function somehow rejects with a non-object, decorateErrorWithCounts
will throw an error which leads to an unhandled rejection.
Example:
const pRetry = require('./');
pRetry(() => Promise.reject(Object.preventExtensions(new Error())))
.catch(console.error);
Expected result:
The retry handler treats the non-extendable like any other (minus the decorating of course).
Actual result:
An UnhandledPromiseRejectionWarning
is generated, the code continues on neither the resolution nor the rejection path.
Generally the code seems to not be well defended against errors from unexpected sources. For example. throwing from the onFailedAttempt
function would also result in an unhandled rejection.
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