-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Description
Does this look like a reasonably safe use of retry?. I am trying to implement a 2-3 attempt retry when something goes awry in my redis subscriber. If it fails after max attempts I will just save to a dead letter queue table in my database (or raise some sort of alert if the the db save fails :))
pubsub.subscribe(`TEST`, async(message) => {
console.log("processing...", message )
var operation = retry.operation({
retries: 2,
factor: 2,
minTimeout: 1 * 1000,
maxTimeout: 60 * 1000,
randomize: false,
});
return operation.attempt(async(currentAttempt) => {
console.log("currentAttempt is",currentAttempt)
let err
try{
//my logic that might fail and throw an error goes here
}catch(whoops){
err = whoops
}
if (operation.retry(err)) {
console.log('returning for a retry...')
return;
}
if(operation.mainError()){
console.log("There was a persistent error, we should save message to a DLQ here:" ,operation.mainError().message)
}
})
})
Metadata
Metadata
Assignees
Labels
No labels