Comments (8)
When would it call onError
? Can you elaborate on what you need and how you would use it?
from p-retry.
await retry(() => foo(), {
onError: (err, attemptNumber, attemptsLeft) => {
console.error(`Attempt number ${attemptNumber} failed: ${err.message} (${attemptsLeft} left)`)
}
})
from p-retry.
@kilianc I mean, in what situation would node-retry
call the onError
function you supply? From your example, it seems like rejecting the promise might be a better option and including the attemptNumber
and attemptsLeft
as properties on the error.
from p-retry.
I think what @kilianc wants is a function to be called after every failed attempt so you can show status updates on network requests or something. So if we go for it, it might be better to call the function onFailure
instead of onError
.
from p-retry.
@SamVerschueren correct. It's mostly for network reattempts. onFailure
and onError
sound exactly the same. maybe onReattempt
?
from p-retry.
onReattempt
I assume this would only be called on the second attempt and forward?
from p-retry.
onFailedAttempt
?
from p-retry.
I've just pushed PR #5 to add this feature.
from p-retry.
Related Issues (20)
- exclude fetchApi "Failed to fetch" from ignores HOT 5
- Cross browser handling of retrying on network connection issues
- Does not support network failures from cross-fetch module HOT 8
- Allow custom 'should be retried' logic HOT 1
- Retry on timeOut HOT 1
- how to stop retry on SIGINT HOT 1
- Use with sinon fake timers HOT 1
- Firefox doesn't retry on TypeError: NetworkError
- Add support for AbortSignal HOT 1
- require/import('p-retry') example for 5.0.0 HOT 1
- Package p-retry has been ignored because it contains invalid configuration HOT 2
- How can I use this on node? There is no cjs export of the library HOT 1
- Check for infinity value in `retries` HOT 2
- Allow wrapping function like `mem` does HOT 2
- SyntaxError: Cannot use import statement outside a module HOT 1
- Backport AbortController to 4.x HOT 1
- No longer useable via TypeScript due to @types/retry dependency release HOT 11
- The documentation of `onFailedAttempt(error)` is incorrect and misleading.
- Support `error.timeout_duration` for `onFailedAttempt`. HOT 2
- Allow importing using require HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p-retry.