returning Error from retry_strategy does not emit on(error) event
See original GitHub issue- Version: node 4.2.1 , redis 2.6.2
- Platform: Mac OS 10.11.5
- Description:
We had implemented a retry_strategy which emits an error after a certain amount of retries. This would then bubble to the on(‘error’) handler of Redis to be logged and exit the application. When updating our redis library from 2.4.2
to 2.6.2
we noticed that this behaviour is no longer the same.
Repro case:
const redis = require('redis');
const MAX_ATTEMPTS = 10;
var client = redis.createClient(port, host, {
retry_strategy: redisRetryStrategy
});
client.on('error', onError);
function OnError(err) {
console.log(err);
throw new Error('SHUTDOWN THE APP, REDIS IS NOT RESPONDING??');
}
function redisRetryStrategy(host, options) {
if (options.attempt >= MAX_ATTEMPTS) {
// Stop reconnecting after reaching the maximum number of attempts
return new Error('Maximum redis reconnect attempts reached');
}
return 1000; // Schedule next reconnection attempt after 1 sec.
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:10 (4 by maintainers)
Top Results From Across the Web
returning Error from retry_strategy does not emit on(error) event
When updating our redis library from 2.4.2 to 2.6.2 we noticed that this behaviour is no longer the same. Repro case: const redis...
Read more >Error handling and automatic retries in AWS Lambda
When you invoke a function, two types of error can occur. Invocation errors occur when the invocation request is rejected before your function...
Read more >Azure Functions error handling and retry guidance
Learn to handle errors and retry events in Azure Functions with links to specific binding errors, including information on retry policies.
Read more >RxJs Error Handling: Complete Practical Guide
the stream has ended its lifecycle with an error; after the error is thrown, the stream will not emit any other values.
Read more >Rxjs - How to retry an errored observable while informing UI of ...
If you materialze the error, then retry() won't retry. If not, then no error will propagate to the downstream. catchError() without rethrowing ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes: Bubble up the error to the error listener
Bubble up ! (or something else)
Custom error emitter like @alannesta wrote is messy,
retry_strategy
is one of the constructor’s parameters, it shouldn’t accessing object that outside the function.NodeRedis
already had an event system, just use it!Since
end
is been taken, and it means “connection is closed”, we can add a new event (let’s just call it “shutdown” for now) that indicating “we did everything we could, this connection is dead, from now on, we do nothing about it, you better do some clean up jobs”.I really need this change.