vercel / fetch-retry Goto Github PK
View Code? Open in Web Editor NEWWrapper around `fetch` with sensible retrying defaults
License: MIT License
Wrapper around `fetch` with sensible retrying defaults
License: MIT License
I am integrating payments for a site and I need to fetch the dollar price for ARS, I need this to make the payment. I am fetching this from a national bank's API but it sometimes fails so I made my own fetch retry, and then started researching for it. I am used to making bots so I need a fault-tolerant fetch, a fetch that will always give you what you need, maybe by providing different source APIs, it would retry or switch until it gets a useful result. I am still trying to understand your code, it seems you are using some knowledge on how fetch retries by itself? I can't see the code looping or increasing attempts.
When there are no retries, it works fine. On retry, it times out and never makes the fetch call again.
Needs license
property in package.json
and a license file.
If we use the same retry values, everywhere we're setting ourselves up for a thundering herd. What happens is that requests tend to line up with each other on the retry intervals over time. So adding jitter will help break up the cycles. Here's a great article from AWS with some data https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
Can i add this to my client side application ?Can i use it to replace fetch?
I dont need node-fetch in as the browser already has the built in fetch.
🚨 You need to enable Continuous Integration on all branches of this repository. 🚨
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.
Since we didn’t receive a CI status on the greenkeeper/initial
branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/
.
Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial
branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.
Hi there 👋 ,
According to the docs, you may add opts.retry to fetch like this:
const opts = { retry: {
retries: 3,
}};
await fetch('url', opts)
But this actually ends up passing the retry directly to fetch as well, even if this is not a valid option in fetch. It is nice that you can override the retry options per fetch invocation, but it would be good if this was not passed to fetch. This causes errors in combination with the nock test tool, as it will not be able to intercept the call anymore.
Suggestion Solution:
fetch-retry should not pass retry options to fetch. This can be done by removing opts.retry
before passing it to fetch.
501 for example means Not Implemented. ie: not worth retrying.
500
502
503
504
make sense instead.
It'd be great to use the changes introduced by #32 👍
Move to:
const fetch = require('fetch-retry')(require('node-fetch'))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.