{"id":13431245,"url":"https://github.com/vercel/async-retry","last_synced_at":"2025-05-13T23:03:55.215Z","repository":{"id":37487453,"uuid":"52813716","full_name":"vercel/async-retry","owner":"vercel","description":"Retrying made simple, easy and async","archived":false,"fork":false,"pushed_at":"2023-07-19T03:46:53.000Z","size":651,"stargazers_count":1875,"open_issues_count":30,"forks_count":53,"subscribers_count":61,"default_branch":"main","last_synced_at":"2025-05-09T07:52:35.004Z","etag":null,"topics":["async","await","javascript","retry"],"latest_commit_sha":null,"homepage":"https://npmjs.com/async-retry","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vercel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-02-29T18:31:57.000Z","updated_at":"2025-05-03T16:08:37.000Z","dependencies_parsed_at":"2023-02-06T11:16:46.370Z","dependency_job_id":"2d0aff0c-3823-4659-abb3-c72bc82d8c67","html_url":"https://github.com/vercel/async-retry","commit_stats":{"total_commits":99,"total_committers":12,"mean_commits":8.25,"dds":0.5252525252525253,"last_synced_commit":"9505be1f829ea297e7aff6c731ca3d5bd7052ed7"},"previous_names":["zeit/async-retry"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Fasync-retry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Fasync-retry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Fasync-retry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Fasync-retry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vercel","download_url":"https://codeload.github.com/vercel/async-retry/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253358171,"owners_count":21895979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","await","javascript","retry"],"created_at":"2024-07-31T02:01:01.621Z","updated_at":"2025-05-13T23:03:55.189Z","avatar_url":"https://github.com/vercel.png","language":"JavaScript","readme":"# async-retry\n\nRetrying made simple, easy, and async.\n\n## Usage\n\n```js\n// Packages\nconst retry = require('async-retry');\nconst fetch = require('node-fetch');\n\nawait retry(\n  async (bail) =\u003e {\n    // if anything throws, we retry\n    const res = await fetch('https://google.com');\n\n    if (403 === res.status) {\n      // don't retry upon 403\n      bail(new Error('Unauthorized'));\n      return;\n    }\n\n    const data = await res.text();\n    return data.substr(0, 500);\n  },\n  {\n    retries: 5,\n  }\n);\n```\n\n### API\n\n```js\nretry(retrier : Function, opts : Object) =\u003e Promise\n```\n\n- The supplied function can be `async` or not. In other words, it can be a function that returns a `Promise` or a value.\n- The supplied function receives two parameters\n  1. A `Function` you can invoke to abort the retrying (bail)\n  2. A `Number` identifying the attempt. The absolute first attempt (before any retries) is `1`.\n- The `opts` are passed to `node-retry`. Read [its docs](https://github.com/tim-kos/node-retry)\n  - `retries`: The maximum amount of times to retry the operation. Default is `10`.\n  - `factor`: The exponential factor to use. Default is `2`.\n  - `minTimeout`: The number of milliseconds before starting the first retry. Default is `1000`.\n  - `maxTimeout`: The maximum number of milliseconds between two retries. Default is `Infinity`.\n  - `randomize`: Randomizes the timeouts by multiplying with a factor between `1` to `2`. Default is `true`.\n  - `onRetry`: an optional `Function` that is invoked after a new retry is performed. It's passed the `Error` that triggered it as a parameter.\n\n## Authors\n\n- Guillermo Rauch ([@rauchg](https://twitter.com/rauchg)) - [Vercel](https://vercel.com)\n- Leo Lamprecht ([@notquiteleo](https://twitter.com/notquiteleo)) - [Vercel](https://vercel.com)\n","funding_links":[],"categories":["JavaScript","目录"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel%2Fasync-retry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvercel%2Fasync-retry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel%2Fasync-retry/lists"}