{"_id":"@bybrave/retry2","name":"@bybrave/retry2","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@bybrave/retry2","version":"1.0.0","description":"Maintained fork of retry — abstraction for exponential-backoff retries, with bundled TypeScript types, an Infinity-retries fix (#84), getTimeout() (#73), and ESM","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"},"scripts":{"build":"node build/build.js","test":"node --test test/*.test.js","test-types":"tsc --noEmit --strict test/type-declarations.ts","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/retry2.git"},"bugs":{"url":"https://github.com/bybraveHQ/retry2/issues"},"homepage":"https://github.com/bybraveHQ/retry2#readme","keywords":["retry","backoff","exponential","timeout","repeat","forever","esm","typescript"],"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"contributors":[{"name":"Tim Koschützki"},{"name":"Felix Geisendörfer","url":"authors of the original retry"}],"license":"MIT","funding":"https://ko-fi.com/bybrave","engines":{"node":">=18"},"devDependencies":{"@types/node":"^20.14.0","esbuild":"^0.23.0","typescript":"^5.5.0"},"_id":"@bybrave/retry2@1.0.0","gitHead":"dd3cc5b11dd9e974ca9bb1a7bc37b6d4e51ff5e4","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-ja/D2xKxL/vpfanmgemUaAlN/brd/ll/csP4SpC345upW8xarfFcx80hiaeSDC0ahnwi+DOl2O119gIBCb+LVw==","shasum":"e2e58f604db19e734e31cfd9332ef67d1dad5cbe","tarball":"https://registry.npmjs.org/@bybrave/retry2/-/retry2-1.0.0.tgz","fileCount":8,"unpackedSize":24260,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD2nIOS3Qj8ZQeTrA+jc3LDXTozXgyebLPsCAdrUH4ADwIhAKUL0bjSWGawS/kFFG1dmuRrj5oYhAcIRfC5KhQSb/UN"}]},"_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/retry2_1.0.0_1783251638058_0.25932198126865424"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-05T11:40:37.827Z","1.0.0":"2026-07-05T11:40:38.216Z","modified":"2026-07-05T11:40:38.403Z"},"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"description":"Maintained fork of retry — abstraction for exponential-backoff retries, with bundled TypeScript types, an Infinity-retries fix (#84), getTimeout() (#73), and ESM","homepage":"https://github.com/bybraveHQ/retry2#readme","keywords":["retry","backoff","exponential","timeout","repeat","forever","esm","typescript"],"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/retry2.git"},"contributors":[{"name":"Tim Koschützki"},{"name":"Felix Geisendörfer","url":"authors of the original retry"}],"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"bugs":{"url":"https://github.com/bybraveHQ/retry2/issues"},"license":"MIT","readme":"# @bybrave/retry2\n\nMaintained, drop-in fork of [`retry`](https://github.com/tim-kos/node-retry) — an abstraction for exponential-backoff retries of failing operations.\n\nThe original has had no release since 2021 (`0.13.1`) while still pulling ~450M downloads/month, with types living in a separate `@types/retry` (~133M/month). This fork **bundles the TypeScript types**, fixes an infinite-retries hang, and ships ESM. The API is unchanged.\n\n```sh\nnpm install @bybrave/retry2\n```\n\n```js\nconst retry = require('@bybrave/retry2');        // CommonJS\nimport retry from '@bybrave/retry2';              // ESM (default)\nimport { operation, timeouts } from '@bybrave/retry2'; // ESM (named)\n```\n\n## What's fixed\n\n| Issue | Problem | Fix |\n|---|---|---|\n| — | Types shipped separately as `@types/retry`. | **Types are bundled** — no extra install. |\n| [#83](https://github.com/tim-kos/node-retry/issues/83) | Under TypeScript 4.4+, `import { timeouts } from 'retry'` compiled to an indirect call and broke because `timeouts()` relied on `this`. | `timeouts()` calls `createTimeout` directly — no `this`, so named imports work everywhere. |\n| [#84](https://github.com/tim-kos/node-retry/issues/84) | `retries: Infinity` built an infinite-length timeouts array — a hang / out-of-memory. | `retries: Infinity` is treated as \"retry forever\" without precomputing an infinite array. |\n| [#73](https://github.com/tim-kos/node-retry/issues/73) | No way to know how long until the next retry (for logging like \"will retry in 16s\"). | New `operation.getTimeout()` returns the scheduled delay in ms. |\n| [#93](https://github.com/tim-kos/node-retry/issues/93) | `undefined` option values overrode the defaults (`{ retries: undefined }` → 0 retries). | `undefined` values are ignored, so defaults stand. |\n| [#65](https://github.com/tim-kos/node-retry/issues/65) | `reset()` left accumulated errors in place. | `reset()` also clears the error list. |\n\n`#60` (forever operations leaking errors) was already fixed in `0.13.1` and is verified by the tests here.\n\n## `operation.getTimeout()`\n\nReturns the delay in milliseconds before the next scheduled attempt (or `null` before the first retry), so you can log it:\n\n```js\nconst op = retry.operation({ retries: 5 });\nop.attempt(() => {\n  doSomething((err) => {\n    if (op.retry(err)) {\n      console.warn(`request failed, retrying in ${op.getTimeout()}ms`);\n      return;\n    }\n  });\n});\n```\n\n## Migration from `retry`\n\nReplace the dependency and the import, and remove `@types/retry` from your devDependencies — the types are built in. Everything behaves the same, plus the fixes above.\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## Credits & license\n\nMIT, same as the original — see [LICENSE](./LICENSE).\nBased on [node-retry](https://github.com/tim-kos/node-retry) by Tim Koschützki, Felix Geisendörfer and contributors.\n","readmeFilename":"README.md","_rev":"1-a4a86baf86909ef193605a897fbb4329"}