question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
BridgeARcommented, Jul 21, 2016

Yes: Bubble up the error to the error listener

3reactions
AaronJancommented, Aug 10, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found