Skip to content

TypeError: options.onFailedAttempt is not a function when onFailedAttempt is null or undefined #36

@gabegorelick

Description

@gabegorelick

A default is provided for the onFailedAttempt option, but only if onFailedAttempt is not in the options object Relevant code:

p-retry/index.js

Lines 31 to 35 in 0608b64

options = {
onFailedAttempt: () => {},
retries: 10,
...options
};

This means that if options.onFailedAttempt is null or undefined, you get a TypeError when attempting to invoke it. But in passing null or undefined, the caller probably wanted to use the default onFailedAttempt handler (I know that's what I want).

This is obviously easy to workaround once you know about it, but does seem like a gotcha.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions