Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ resume sending when you get `drain`.

`client` will emit `idle` when there are no outstanding commands that are awaiting a response.

### "reconnecting"

`client` will emit `reconnecting` when trying to reconnect to the Redis server after losing the connection. Listeners
are passed an object containing `delay` (in ms) and `attempt` (the attempt #) attributes.

## redis.createClient(port, host, options)

Create a new client connection. `port` defaults to `6379` and `host` defaults
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,10 @@ RedisClient.prototype.connection_gone = function (why) {
if (this.max_attempts && this.attempts >= this.max_attempts) {
this.retry_timer = null;
// TODO - some people need a "Redis is Broken mode" for future commands that errors immediately, and others
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove both TODOs including the console.error

// want the program to exit. Right now, we just log, which doesn't really help in either case.
// want the program to exit. Right now, we just log, which doesn't really help in either case, and emit
// an error event.
console.error("node_redis: Couldn't get Redis connection after " + this.max_attempts + " attempts.");
this.emit('error', new Error("Redis connection in broken state"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To distinguish this error from the other one it would be good to use different error messages. E.g.: Redis connection in broken state: maximum connection attempts exceeded." and "Redis connection in broken state: connection timeout exceeded.".

And please add a note in the readme about the emitted errors after exceeding the limit. Thx

return;
}

Expand All @@ -529,6 +531,7 @@ RedisClient.prototype.connection_gone = function (why) {
self.retry_timer = null;
// TODO - engage Redis is Broken mode for future commands, or whatever
console.error("node_redis: Couldn't get Redis connection after " + self.retry_totaltime + "ms.");
this.emit('error', new Error("Redis connection in broken state"));
return;
}

Expand Down