{"versions":{"6.2.0-2":{"name":"@n8n/p-retry","version":"6.2.0-2","description":"Retry a promise-returning or async function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-retry.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"main":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=18.10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","retry","retries","operation","failed","rejected","try","exponential","backoff","attempt","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"@types/retry":"^0.12.5","retry":"0.13.1","@common.js/is-network-error":"1.0.1"},"devDependencies":{"ava":"^5.3.1","delay":"^6.0.0","tsd":"^0.28.1","xo":"^0.56.0"},"_id":"@n8n/p-retry@6.2.0-2","gitHead":"5ceea09e477c3f3906ac682b3c095f29a91498f2","bugs":{"url":"https://github.com/sindresorhus/p-retry/issues"},"homepage":"https://github.com/sindresorhus/p-retry#readme","_nodeVersion":"18.18.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-rbnMnSdEwq2yuYMgzOQ4jTXm+oH7yjN/0ISfB/7O6pUcEPsZt9UW60BYfQ1WWHkKa/evI8vgER2zV5/RC1BupQ==","shasum":"88d9f01f487f9fa1cbb138404b72ce1d8692c484","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@n8n/p-retry/-/p-retry-6.2.0-2.tgz","fileCount":5,"unpackedSize":13325,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDUyKgb4Bz4+hzJlunk7G+MbToxvltNs+d2XqbpVwVdpgIgRzZw0CX64IY6r/NV2UzB6TYH0MABDN/AByrc0jH7gd0="}],"size":4233},"_npmUser":{"name":"anonymous","email":"npm@netroy.in"},"directories":{},"maintainers":[{"name":"anonymous","email":"alex@grozav.com"},{"name":"anonymous","email":"ivov.src@gmail.com"},{"name":"anonymous","email":"milorad.filipovic19@gmail.com"},{"name":"anonymous","email":"npm@netroy.in"},{"name":"anonymous","email":"jan@n8n.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-retry_6.2.0-2_1710418180887_0.44644698173395625"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-03-14T12:09:41.046Z","publish_time":1710418181046,"_source_registry_name":"default","contributors":[]},"6.2.0-1":{"name":"@n8n/p-retry","version":"6.2.0-1","description":"Retry a promise-returning or async function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-retry.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"main":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=18.10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","retry","retries","operation","failed","rejected","try","exponential","backoff","attempt","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"@types/retry":"^0.12.5","retry":"0.13.1","@common.js/is-network-error":"1.0.1"},"devDependencies":{"ava":"^5.3.1","delay":"^6.0.0","tsd":"^0.28.1","xo":"^0.56.0"},"_id":"@n8n/p-retry@6.2.0-1","gitHead":"b0489c4b30e0324ca0d3bc82b0070ae1f58f0bd9","bugs":{"url":"https://github.com/sindresorhus/p-retry/issues"},"homepage":"https://github.com/sindresorhus/p-retry#readme","_nodeVersion":"18.18.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-uM6EbaKSznVN4ETXA1H805vGF+KSXQ4+JvJOntUOsm3pGL2mgrOI+N3X/SlmApC1EhACe7uZvNgpaa3SXpp1kQ==","shasum":"a0a79af750db729050a3d689d2a6fe8dcf2051ef","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@n8n/p-retry/-/p-retry-6.2.0-1.tgz","fileCount":5,"unpackedSize":13313,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzFOzjploCFsB7pOizKtWDqwN+jGGebRPJ4FXhLfCNzgIgB4VE1LKzPP6nlm4iXmTmB86d1sIZKnv6AES71V9gMdQ="}],"size":4227},"_npmUser":{"name":"anonymous","email":"npm@netroy.in"},"directories":{},"maintainers":[{"name":"anonymous","email":"alex@grozav.com"},{"name":"anonymous","email":"ivov.src@gmail.com"},{"name":"anonymous","email":"milorad.filipovic19@gmail.com"},{"name":"anonymous","email":"npm@netroy.in"},{"name":"anonymous","email":"jan@n8n.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-retry_6.2.0-1_1710416315171_0.3897511186271858"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-03-14T11:38:35.316Z","publish_time":1710416315316,"_source_registry_name":"default","contributors":[]},"6.2.0":{"name":"@n8n/p-retry","version":"6.2.0","description":"Retry a promise-returning or async function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-retry.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"main":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=18.10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","retry","retries","operation","failed","rejected","try","exponential","backoff","attempt","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"retry":"0.13.1","@common.js/is-network-error":"1.0.1"},"devDependencies":{"@types/retry":"^0.12.5","ava":"^5.3.1","delay":"^6.0.0","tsd":"^0.28.1","xo":"^0.56.0"},"_id":"@n8n/p-retry@6.2.0","gitHead":"31df29210c77f803c3315f1f18b1f267e3e4bafd","bugs":{"url":"https://github.com/sindresorhus/p-retry/issues"},"homepage":"https://github.com/sindresorhus/p-retry#readme","_nodeVersion":"18.18.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-ESsx3OXyKX8Z8tzlRZVZojQDbfcUOo8XiaCmQC7aSi66G2H33J5t84y821Ei2OD6HRfoMQBiafD7zuptqAPSFg==","shasum":"212d97bddf76f690ec6368f270ffad51d1130f28","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@n8n/p-retry/-/p-retry-6.2.0.tgz","fileCount":5,"unpackedSize":13250,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHIyASkl0Rqz6UVxqAqBlMGl+QUTmKSau9mTFW/0L4ACAiEA4Pkk0JvtFjFXjZSatcQtz2AyAOUb7XJjpy1YDDASXIQ="}],"size":4196},"_npmUser":{"name":"anonymous","email":"npm@netroy.in"},"directories":{},"maintainers":[{"name":"anonymous","email":"alex@grozav.com"},{"name":"anonymous","email":"ivov.src@gmail.com"},{"name":"anonymous","email":"milorad.filipovic19@gmail.com"},{"name":"anonymous","email":"npm@netroy.in"},{"name":"anonymous","email":"jan@n8n.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-retry_6.2.0_1710414490889_0.8176561971100127"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-03-14T11:08:11.062Z","publish_time":1710414491062,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"6.2.0-2"},"name":"@n8n/p-retry","time":{"created":"2024-03-14T14:06:03.538Z","modified":"2026-02-11T10:46:50.090Z","6.2.0-2":"2024-03-14T12:09:41.046Z","6.2.0-1":"2024-03-14T11:38:35.316Z","6.2.0":"2024-03-14T11:08:11.062Z"},"readme":"# p-retry\n\n> Retry a promise-returning or async function\n\nIt does exponential backoff and supports custom retry strategies for failed operations.\n\n## Install\n\n```sh\nnpm install p-retry\n```\n\n## Usage\n\n```js\nimport pRetry, {AbortError} from 'p-retry';\nimport fetch from 'node-fetch';\n\nconst run = async () => {\n\tconst response = await fetch('https://sindresorhus.com/unicorn');\n\n\t// Abort retrying if the resource doesn't exist\n\tif (response.status === 404) {\n\t\tthrow new AbortError(response.statusText);\n\t}\n\n\treturn response.blob();\n};\n\nconsole.log(await pRetry(run, {retries: 5}));\n```\n\n## API\n\n### pRetry(input, options?)\n\nReturns a `Promise` that is fulfilled when calling `input` returns a fulfilled promise. If calling `input` returns a rejected promise, `input` is called again until the maximum number of retries is reached. It then rejects with the last rejection reason.\n\nIt does not retry on most `TypeError`'s, with the exception of network errors. This is done on a best case basis as different browsers have different [messages](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Checking_that_the_fetch_was_successful) to indicate this. See [whatwg/fetch#526 (comment)](https://github.com/whatwg/fetch/issues/526#issuecomment-554604080)\n\n#### input\n\nType: `Function`\n\nReceives the current attempt number as the first argument and is expected to return a `Promise` or any value.\n\n#### options\n\nType: `object`\n\nOptions are passed to the [`retry`](https://github.com/tim-kos/node-retry#retryoperationoptions) module.\n\n##### onFailedAttempt(error)\n\nType: `Function`\n\nCallback invoked on each retry. Receives the error thrown by `input` as the first argument with properties `attemptNumber` and `retriesLeft` which indicate the current attempt number and the number of attempts left, respectively.\n\n```js\nimport pRetry from 'p-retry';\n\nconst run = async () => {\n\tconst response = await fetch('https://sindresorhus.com/unicorn');\n\n\tif (!response.ok) {\n\t\tthrow new Error(response.statusText);\n\t}\n\n\treturn response.json();\n};\n\nconst result = await pRetry(run, {\n\tonFailedAttempt: error => {\n\t\tconsole.log(`Attempt ${error.attemptNumber} failed. There are ${error.retriesLeft} retries left.`);\n\t\t// 1st request => Attempt 1 failed. There are 4 retries left.\n\t\t// 2nd request => Attempt 2 failed. There are 3 retries left.\n\t\t// …\n\t},\n\tretries: 5\n});\n\nconsole.log(result);\n```\n\nThe `onFailedAttempt` function can return a promise. For example, you can do some async logging:\n\n```js\nimport pRetry from 'p-retry';\nimport logger from './some-logger';\n\nconst run = async () => { … };\n\nconst result = await pRetry(run, {\n\tonFailedAttempt: async error => {\n\t\tawait logger.log(error);\n\t}\n});\n```\n\nIf the `onFailedAttempt` function throws, all retries will be aborted and the original promise will reject with the thrown error.\n\n##### shouldRetry(error)\n\nType: `Function`\n\nDecide if a retry should occur based on the error. Returning true triggers a retry, false aborts with the error.\n\nIt is not called for `TypeError` (except network errors) and `AbortError`.\n\n```js\nimport pRetry from 'p-retry';\n\nconst run = async () => { … };\n\nconst result = await pRetry(run, {\n\tshouldRetry: error => !(error instanceof CustomError);\n});\n```\n\nIn the example above, the operation will be retried unless the error is an instance of `CustomError`.\n\n##### signal\n\nType: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\nYou can abort retrying using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).\n\n```js\nimport pRetry from 'p-retry';\n\nconst run = async () => { … };\nconst controller = new AbortController();\n\ncancelButton.addEventListener('click', () => {\n\tcontroller.abort(new Error('User clicked cancel button'));\n});\n\ntry {\n\tawait pRetry(run, {signal: controller.signal});\n} catch (error) {\n\tconsole.log(error.message);\n\t//=> 'User clicked cancel button'\n}\n```\n\n### AbortError(message)\n### AbortError(error)\n\nAbort retrying and reject the promise.\n\n### message\n\nType: `string`\n\nAn error message.\n\n### error\n\nType: `Error`\n\nA custom error.\n\n## Tip\n\nYou can pass arguments to the function being retried by wrapping it in an inline arrow function:\n\n```js\nimport pRetry from 'p-retry';\n\nconst run = async emoji => {\n\t// …\n};\n\n// Without arguments\nawait pRetry(run, {retries: 5});\n\n// With arguments\nawait pRetry(() => run('🦄'), {retries: 5});\n```\n\n## Related\n\n- [p-timeout](https://github.com/sindresorhus/p-timeout) - Timeout a promise after a specified amount of time\n- [More…](https://github.com/sindresorhus/promise-fun)","users":{}}