Skip to content

Non-extensible rejections result in unhandled rejection #25

@openreply-dleinhaeuser

Description

@openreply-dleinhaeuser

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions