Comments (7)
Hey ladies and gentlemen,
I will look into this soon. I am just really busy with Transloadit right now.
Sorry for the delay. :/
from node-retry.
Not sure why this happens, however I've opted to use the following approach until we can figure this issue out:
const maxAttempts = 3;
let attempt = 1;
while (attempt <= maxAttempts) {
try {
console.log(`doing ${attempt}: ${command}`);
const execResult = await execPromise(command);
// Do something with execResult
cosole.log(execResult)
break;
} catch (e) {
this.log.error(e);
// Sleep using linear backoff strategy (5s after first attempt, 10s after second attempt)
if (attempt < maxAttempt) {
await new Promise(resolve => setTimeout(resolve, 5000 * attempt));
}
attempt += 1;
}
}
from node-retry.
So you are getting the same issue as me? Do you also get it with node-promise-retry?
See my issue in IndigoUnited/node-promise-retry#14, I'm getting it there too.
from node-retry.
@rightaway Yep same issue. I don't use node-promise-retry
but it's just a wrapper around node-retry
so it makes sense that you encountered this issue there as well.
from node-retry.
FWIW, the following test program seems to work fine for me.
const retry = require("retry");
const sleep = timeout =>
new Promise(resolve => setTimeout(resolve, timeout));
function log(msg) {
console.log(`${new Date().toLocaleString()}: ${msg}`);
}
async function asyncThrow() {
await sleep(1000);
throw 'whoops';
}
const operation = retry.operation({
retries: 3,
factor: 2,
maxTimeout: 10000,
randomize: true
});
operation.attempt(async (attemptNumber) => {
try {
log(`attemptNumber = ${attemptNumber} - calling asyncThrow`);
await asyncThrow();
}
catch(err) {
if (operation.retry(err)) {
log('retrying.');
} else {
log('giving up.');
}
}
});
Here's the output I get:
2017-11-20 14:34:00: attemptNumber = 1 - calling asyncThrow
2017-11-20 14:34:01: retrying.
2017-11-20 14:34:02: attemptNumber = 2 - calling asyncThrow
2017-11-20 14:34:03: retrying.
2017-11-20 14:34:07: attemptNumber = 3 - calling asyncThrow
2017-11-20 14:34:08: retrying.
2017-11-20 14:34:13: attemptNumber = 4 - calling asyncThrow
2017-11-20 14:34:14: giving up.
from node-retry.
Hm okay, thanks for doing this.
@rightaway Do you mind posting your complete code here?
from node-retry.
Closing this then for now, because the error is unlikely in node-retry, but rather in the userland code. @avranju 's example works as expected.
from node-retry.
Related Issues (20)
- [Feature Request] Add Promise Support HOT 6
- [Feature Request] CLI command support for shell users
- Update npm package version HOT 1
- [Docs] Question about factor
- [Bug] RetryOperation does not free errors correctly, causing "forever" operations to leak memory
- Needs keywords section is package.json HOT 1
- Unable to clear the current running timer and exit the retry loop HOT 4
- operation.reset() is somewhat unintuitive HOT 1
- Retry a http request HOT 1
- Include previous error even if there's a timeout
- It would be useful if the retry function returned the timout number HOT 4
- When is the next release (with changes from master) scheduled to go out to npm? HOT 4
- node-retry retry.operation is being called only once with jest.fn promise reject mocks HOT 1
- PR suggestion: withRetry wrapper HOT 1
- Missing current attempt in callback
- Typescript 4.4 breaking change affect retry HOT 1
- Check for infinity value in `retries` HOT 2
- Is this the way ? HOT 1
- Setting maxTimeout to undefined breaks minTimeout behavior
- Ability to set timeout for each retry?
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 node-retry.