-
-
Notifications
You must be signed in to change notification settings - Fork 74
Closed
Labels
Description
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.
wrumsby