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.

retry_strategy doesn't reset after flushing the error

See original GitHub issue
  • Version: node_redis 2.6.5, redis 3.2.7
  • Platform: Node.js 7.5.0 on Mac OS 10.12.3
  • Description:

I’m using the following code

const redis = require('redis');

const client = redis.createClient({
  url: 'redis://localhost:6379',
  retry_strategy: options => new Error('Fail')
});

setInterval(() => client.incr('some-key', console.log), 5000);

running against a local redis (docker run --rm -p 6379:6379 redis)

After I see the first output, I kill the redis to simulate disconnect. When I’ve seen the error come in I restart the redis. The connection doesn’t come up again. I would expect that after flushing the error to the offline handlers, the client would try to reconnect on the next command. instead it stays in closed state. Also it’s returning with AbortError instead of new Error('Fail').

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:21 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
newhousecommented, Apr 20, 2017

Quick update here. I added the enable_offline_queue = false to my createClient options, and it seems to have done what I wanted it to, which is: “Continue to attempt to re-connect to my Redis server based on the retry_strategy function, but immediately throw errors in response to attempts to use the client in the meantime. Then, if able to reconnect, just start working again”.

FYI: Thows the following error on a get call: AbortError: SET can't be processed. Stream not writeable.

For my usage as a straight layer between the DB and my app, this should be fine. Would be nice to know if there’s a more “robust” solution possible where:

  • Client continues to attempt to reconnect based on retry_strategy
  • Calls/consumers/users of the Client don’t hang while it’s reconnecting
  • Commands can still be queued (conditionally?) to be executed if/when a connection is re-established…in case I’m incrementing things, etc.

Probably a lot of tough scenarios to consider here…

7reactions
Janpotcommented, Apr 4, 2019

@BridgeAR It’s pretty much that right now, if redis connection breaks for some reason, all my commands just hang. Suppose I have a fallback for the operation that redis is doing then that fallback also hangs. I’d rather want redis to return an error after a few retries, which I can catch and employ the fallback. That doesn’t mean I don’t want the client to stop trying to connect. Redis might come back up in a minute.

I just don’t see the point of the current behavior. You return an error in the retry handler and then your client just dies forever. Who needs that sort of behavior unless you create a client for every command?

Or I might not see the use case for that ofcourse 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

retry_strategy doesn't reset after flushing the error · Issue #1198
When I've seen the error come in I restart the redis. The connection doesn't come up again. I would expect that after flushing...
Read more >
Establish 'connection retry' behaviour on start-up even when ...
If the Redis instance becomes unavailable, use of an appropriate retry_strategy means the client can be set up to try to reconnect until...
Read more >
AsyncBucket (Couchbase Java SDK) - Couchbase Documentation
Defines operations that can be executed asynchronously against a Couchbase Server bucket. Note that only a subset of the provided operations are available ......
Read more >
How to reset / flush permalinks and fix permalink problems in ...
Resetting / Flushing permalinks structure · In the Admin menu, click on Settings > Permalinks · Then, when on the Permalinks Settings page,...
Read more >
Problems with Entities in Messages > Messenger! Queue work ...
Until you restart it, it still has the old code stored in memory! ... Then, when we call flush() , Doctrine loops over...
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