async-retry
async-retry copied to clipboard
Option has no retries
I haven't followed the details of whether the type of @types/retry has changed, but I got an error that option has no "retries", and I couldn't use this package.
const retry = require('async-retry');
const fetch = require('node-fetch');
await retry(
async (bail) => {
// if anything throws, we retry
const res = await fetch('https://google.com');
if (403 === res.status) {
// don't retry upon 403
bail(new Error('Unauthorized'));
return;
}
const data = await res.text();
return data.substr(0, 500);
},
{
// Not Found
retries: 5,
}
);
Im having this issue as well.
@yogarasu are you using Typescript 3 or 4. I had this issue when using the latest version of the types package on TS3.
Fix the @types package at 1.3.0 and the issue may also go away.
Can confirm that npm i -D @types/[email protected] works, the latest version of the types definition has this code:
import { WrapOptions } from 'retry';
But the version of @types/retry that got automatically downloaded didn't have that (I'm using [email protected]).
Managed to fix it by running npm i -D @types/retry@latest @types/async-retry@latest
Installing @types/retry solved it for me.