{"id":15154836,"url":"https://github.com/vercel/fetch-retry","last_synced_at":"2025-09-30T03:30:52.962Z","repository":{"id":44843830,"uuid":"106888399","full_name":"vercel/fetch-retry","owner":"vercel","description":"Wrapper around `fetch` with sensible retrying defaults","archived":true,"fork":false,"pushed_at":"2022-02-11T19:55:28.000Z","size":495,"stargazers_count":223,"open_issues_count":13,"forks_count":18,"subscribers_count":58,"default_branch":"master","last_synced_at":"2024-09-27T18:01:13.532Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-14T01:32:50.000Z","updated_at":"2024-09-17T03:35:05.000Z","dependencies_parsed_at":"2022-09-24T23:22:50.794Z","dependency_job_id":null,"html_url":"https://github.com/vercel/fetch-retry","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Ffetch-retry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Ffetch-retry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Ffetch-retry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Ffetch-retry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vercel","download_url":"https://codeload.github.com/vercel/fetch-retry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234695627,"owners_count":18873012,"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":[],"created_at":"2024-09-26T18:00:49.896Z","updated_at":"2025-09-30T03:30:47.677Z","avatar_url":"https://github.com/vercel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fetch-retry\n\n**This repo has been archived and the source has been moved to [vercel/fetch](https://github.com/vercel/fetch) monorepo**\n\nA layer on top of `fetch` (via [node-fetch](https://www.npmjs.com/package/node-fetch))\nwith sensible defaults for retrying to prevent common errors.\n\n## How to use\n\n`fetch-retry` is a drop-in replacement for `fetch`:\n\n```js\nconst fetch = require('@vercel/fetch-retry')(require('node-fetch'))\n\nmodule.exports = async () =\u003e {\n  const res = await fetch('http://localhost:3000')\n  console.log(res.status);\n}\n```\n\nMake sure to `yarn add @vercel/fetch-retry` in your main package.\n\nNote that you can pass [retry options](https://github.com/vercel/async-retry) to using `opts.retry`.\nWe also provide a `opts.onRetry` and `opts.retry.maxRetryAfter` options.\n\n`opts.onRetry` is a customized version of `opts.retry.onRetry` and passes\nnot only the `error` object in each retry but also the current `opts` object.\n\n`opts.retry.maxRetryAfter` is the max wait time according to the `Retry-After` header.\nIf it exceeds the option value, stop retrying and returns the error response. It defaults to `20`.\n\n## Rationale\n\nSome errors are very common in production (like the underlying `Socket`\nyielding `ECONNRESET`), and can easily and instantly be remediated\nby retrying.\n\nThe default behavior of `fetch-retry` is to attempt retries **10**, **60**\n**360**, **2160** and **12960** milliseconds (a total of 5 retries) after\na *network error*, *429* or *5xx* error occur.\n\nThe idea is to provide a sensible default: most applications should\ncontinue to perform correctly with a worst case scenario of a given\nrequest having an additional 15550ms overhead.\n\nOn the other hand, most applications that use `fetch-retry` instead of\nvanilla `fetch` should see lower rates of common errors and fewer 'glitches'\nin production.\n\n## Tests\n\nTo run rests, execute\n\n```console\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel%2Ffetch-retry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvercel%2Ffetch-retry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel%2Ffetch-retry/lists"}