Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update readme.md #81

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GiovaniMFMurari
Copy link

Fix onFailedAttempt explanation logs returns so its precise to the way the lib actually works.

Used the following in order to test it:

import pRetry from 'p-retry';

(async () => {
  const run = async () => {
    console.log('running');
    throw new Error('something');
  };

  const result = await pRetry(run, {
    onFailedAttempt: (error) => {
      console.log(
        `Attempt ${error.attemptNumber} failed. There are ${error.retriesLeft} retries left.`,
      );
    },
    retries: 5,
  });
})();

The actual expected result is:

running
Attempt 1 failed. There are 5 retries left.
running
Attempt 2 failed. There are 4 retries left.
running
Attempt 3 failed. There are 3 retries left.
running
Attempt 4 failed. There are 2 retries left.
running
Attempt 5 failed. There are 1 retries left.
running
Attempt 6 failed. There are 0 retries left.
/home/giovani/test.ts:6
    throw new Error('something');

Fix onFailedAttempt explanation logs returns so its precise to the way the lib actually works.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant