{"_id":"@bybrave/async-retry2","_rev":"3-a2ab4e15c8c4fef109d932072f0601e0","name":"@bybrave/async-retry2","dist-tags":{"latest":"2.0.2"},"versions":{"2.0.0":{"name":"@bybrave/async-retry2","version":"2.0.0","keywords":["async","retry","retries","promise","backoff","esm","typescript"],"author":{"name":"bybrave"},"license":"MIT","_id":"@bybrave/async-retry2@2.0.0","maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"homepage":"https://github.com/bybraveHQ/async-retry2#readme","bugs":{"url":"https://github.com/bybraveHQ/async-retry2/issues"},"dist":{"shasum":"4999002e93475ae3a0a7fbaaabf385b6bb3fa972","tarball":"https://registry.npmjs.org/@bybrave/async-retry2/-/async-retry2-2.0.0.tgz","fileCount":9,"integrity":"sha512-efIY+ABF7fudNEjwtkBS4sO6tMasxU6ohBN0WMXvkIL2ecALku0a9F0lPQ3+PlxUWiAPTDVVLewYuloOOwiQGg==","signatures":[{"sig":"MEYCIQCYDJeIBf6O7q2SriXsdIhStC43Pe4yDt9YCHjyInM/rQIhAItm/+z9dJa4R/049Vlq5yw1m45HGH8jFLxMiXPs2pAf","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26363},"main":"./dist/index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","engines":{"node":">=18"},"exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"15cea20aa3c8e1309c97418767aa565b314ba7b2","scripts":{"test":"node --test","build":"node build/build.js","test-types":"tsc --strict --noEmit --moduleResolution bundler --target es2020 --lib es2020,dom --types node test/types.ts","prepublishOnly":"npm run build && npm test && npm run test-types"},"_npmUser":{"name":"bybrave","email":"opmybrave@gmail.com"},"repository":{"url":"git+https://github.com/bybraveHQ/async-retry2.git","type":"git"},"_npmVersion":"10.8.2","description":"Maintained async-retry fork: zero runtime dependencies, ESM + CommonJS, built-in TypeScript types, bail actually stops retries, AbortSignal + shouldRetry support. Drop-in for async-retry.","directories":{},"sideEffects":false,"_nodeVersion":"20.19.6","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.24.0","typescript":"^5.6.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/async-retry2_2.0.0_1783257950280_0.6461785787599579","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@bybrave/async-retry2","version":"2.0.1","keywords":["async","retry","retries","promise","backoff","esm","typescript"],"author":{"name":"bybrave"},"license":"MIT","_id":"@bybrave/async-retry2@2.0.1","maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"homepage":"https://github.com/bybraveHQ/async-retry2#readme","bugs":{"url":"https://github.com/bybraveHQ/async-retry2/issues"},"dist":{"shasum":"bd685afe596fe6f844289c29814c74cb62c29f9a","tarball":"https://registry.npmjs.org/@bybrave/async-retry2/-/async-retry2-2.0.1.tgz","fileCount":9,"integrity":"sha512-A9fEuzv7JjLttElba7OQQDk6N+Z39BugY3dJBdJECZ3BS41/zTqhJh50r+aGzZR74TjkGJK1fuXFtgoXQFHPJA==","signatures":[{"sig":"MEQCIDqlb1P1759GTVx3puSneG/SXd4mw9EqhYZ7YONBH+XsAiAuYqo0iSL8cTFBbrdcJGpCmGcY5i8vxMz9HuJaBN/V8Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26568},"main":"./dist/index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","engines":{"node":">=18"},"exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"01aed89f1c558691db7e8893e1e8229bff9968bd","scripts":{"test":"node --test","build":"node build/build.js","test-types":"tsc --strict --noEmit --moduleResolution bundler --target es2020 --lib es2020,dom --types node test/types.ts","prepublishOnly":"npm run build && npm test && npm run test-types"},"_npmUser":{"name":"bybrave","email":"opmybrave@gmail.com"},"repository":{"url":"git+https://github.com/bybraveHQ/async-retry2.git","type":"git"},"_npmVersion":"10.8.2","description":"Maintained async-retry fork: zero runtime dependencies, ESM + CommonJS, built-in TypeScript types, bail actually stops retries, AbortSignal + shouldRetry support. Drop-in for async-retry.","directories":{},"sideEffects":false,"_nodeVersion":"20.19.6","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.24.0","typescript":"^5.6.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/async-retry2_2.0.1_1783296344726_0.2624769153804989","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"@bybrave/async-retry2","version":"2.0.2","description":"Maintained async-retry fork: zero runtime dependencies, ESM + CommonJS, built-in TypeScript types, bail actually stops retries, AbortSignal + shouldRetry support. Drop-in for async-retry.","type":"module","main":"./dist/index.cjs","module":"./index.js","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"sideEffects":false,"scripts":{"build":"node build/build.js","test":"node --test","test-types":"tsc --strict --noEmit --moduleResolution bundler --target es2020 --lib es2020,dom --types node test/types.ts","prepublishOnly":"npm run build && npm test && npm run test-types"},"keywords":["async","retry","retries","promise","backoff","esm","typescript"],"author":{"name":"bybrave"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/bybraveHQ/async-retry2.git"},"bugs":{"url":"https://github.com/bybraveHQ/async-retry2/issues"},"homepage":"https://github.com/bybraveHQ/async-retry2#readme","engines":{"node":">=18"},"devDependencies":{"esbuild":"^0.24.0","typescript":"^5.6.0","@types/node":"^22.0.0"},"_id":"@bybrave/async-retry2@2.0.2","gitHead":"62946e2d6d3e611445d73e5eb35e0fb465933321","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-rtYDVCzhuTkNvDoTIcFc0r2I6pnBQKvCJW/3r4Fpx7B3DvKsFaonD9OglP27fiEdh9H9QWAT+WZxlat/9+cIcA==","shasum":"40115be2c144aad6224c22f69ec8fd88063eb408","tarball":"https://registry.npmjs.org/@bybrave/async-retry2/-/async-retry2-2.0.2.tgz","fileCount":9,"unpackedSize":26730,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEttnh3P4+O77Qihe8Sk8QTilYB31IPPQzCIBMPmYBpXAiACTfTIKuKYXOBJtP1SaEojI4OyYGkrG7Cmyk0o2f9FzA=="}]},"_npmUser":{"name":"bybrave","email":"opmybrave@gmail.com"},"directories":{},"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/async-retry2_2.0.2_1783297103602_0.1816793796921632"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-05T13:25:50.101Z","modified":"2026-07-06T00:18:23.846Z","2.0.0":"2026-07-05T13:25:50.416Z","2.0.1":"2026-07-06T00:05:44.866Z","2.0.2":"2026-07-06T00:18:23.743Z"},"bugs":{"url":"https://github.com/bybraveHQ/async-retry2/issues"},"author":{"name":"bybrave"},"license":"MIT","homepage":"https://github.com/bybraveHQ/async-retry2#readme","keywords":["async","retry","retries","promise","backoff","esm","typescript"],"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/async-retry2.git"},"description":"Maintained async-retry fork: zero runtime dependencies, ESM + CommonJS, built-in TypeScript types, bail actually stops retries, AbortSignal + shouldRetry support. Drop-in for async-retry.","maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"readme":"# @bybrave/async-retry2\n\nMaintained fork of [`async-retry`](https://www.npmjs.com/package/async-retry) — retrying made simple, easy, and async.\n\nSame API, **zero runtime dependencies** (node-retry is vendored in), dual **ESM + CommonJS**, **built-in TypeScript types**, and a `bail()` that actually stops retrying.\n\n## Install\n\n```sh\nnpm install @bybrave/async-retry2\n```\n\n## Usage\n\n```js\nimport retry from '@bybrave/async-retry2';\n\nawait retry(\n  async (bail, attempt) => {\n    const res = await fetch('https://example.com');\n    if (res.status === 403) {\n      bail(new Error('Unauthorized')); // stops retrying immediately\n      return;\n    }\n    return res.text();\n  },\n  { retries: 5 }\n);\n```\n\nCommonJS works too — `require` returns the function directly:\n\n```js\nconst retry = require('@bybrave/async-retry2');\n```\n\nThe supplied function receives `(bail, attempt)`: call `bail(error)` to abort retrying, `attempt` is the 1-based attempt number.\n\n### Options\n\nPassed through to node-retry, plus fork additions:\n\n| Option | Default | Effect |\n|---|---|---|\n| `retries` | `10` | Maximum number of retries. |\n| `factor` | `2` | Exponential backoff factor. |\n| `minTimeout` | `1000` | Milliseconds before the first retry. |\n| `maxTimeout` | `Infinity` | Maximum milliseconds between retries. |\n| `randomize` | `true` | Multiply timeouts by a random `1`–`2` factor. |\n| `onRetry` | — | `(error, attempt) => void \\| Promise<void>` after each failed attempt. May be async. |\n| `shouldRetry` | — | `(error) => boolean` — return `false` to stop retrying this error. **(fork, #51)** |\n| `signal` | — | `AbortSignal` to abort the whole operation, e.g. `AbortSignal.timeout(5000)`. **(fork, #73)** |\n\n## What's fixed vs `async-retry@1.3.3`\n\n| Issue | Fix |\n|---|---|\n| [#69](https://github.com/vercel/async-retry/issues/69) | `bail()` now actually stops the operation — no further attempts run and the retrier function is never called again after bail. Previously bail only rejected the promise while retries kept firing. |\n| [#103](https://github.com/vercel/async-retry/issues/103) | Ships as native ESM with a CommonJS build via the `exports` map — no more `(0 , async_retry_1.retry) is not a function`. `import` and `require` both work. |\n| [#110](https://github.com/vercel/async-retry/issues/110), [#54](https://github.com/vercel/async-retry/issues/54) | Built-in TypeScript types (no separate `@types/async-retry` needed), including the `attempt` parameter. |\n| [#51](https://github.com/vercel/async-retry/issues/51) | New `shouldRetry(error)` option to decide per-error whether to keep retrying. |\n| [#43](https://github.com/vercel/async-retry/issues/43) | `onRetry` may be `async`; a rejection from it is swallowed instead of becoming an unhandled rejection. |\n| [#73](https://github.com/vercel/async-retry/issues/73) | New `signal` option (`AbortSignal`) to time out or cancel the entire retry operation. |\n| — | Zero runtime dependencies — `retry` is vendored and maintained in-tree. |\n\n## Migration from `async-retry`\n\nDrop-in — replace the import:\n\n```diff\n- const retry = require('async-retry');\n+ const retry = require('@bybrave/async-retry2');\n```\n\nThe retry/backoff behaviour is unchanged. The one intentional behaviour change is [#69](https://github.com/vercel/async-retry/issues/69): after you call `bail()`, the function is no longer retried (this is what most people already expected).\n\n## Support\n\nIf this package saves you time, you can support maintenance:\n\n[![Ko-fi](https://img.shields.io/badge/Ko--fi-buy%20me%20a%20coffee-FF5E5B?logo=kofi&logoColor=white)](https://ko-fi.com/bybrave)\n[![Bitcoin](https://img.shields.io/badge/Bitcoin-BTC-F7931A?logo=bitcoin&logoColor=white)](#support)\n\nBitcoin (BTC): `bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q`\n\n## License\n\nMIT. Copyright © Vercel, Inc.; vendored node-retry © Tim Koschützki, Felix Geisendörfer; fork © bybrave.\n","readmeFilename":"README.md"}