You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
Merge remote branch 'tw/connection-fixes'
This commit is contained in:
4
index.js
4
index.js
@@ -390,7 +390,7 @@ RedisClient.prototype.connection_gone = function () {
|
||||
console.warn("Redis connection is gone.");
|
||||
}
|
||||
self.connected = false;
|
||||
self.emit("close");
|
||||
self.emit("end");
|
||||
self.command_queue.forEach(function (args) {
|
||||
if (typeof args[2] === "function") {
|
||||
args[2]("Server connection closed");
|
||||
@@ -410,7 +410,7 @@ RedisClient.prototype.connection_gone = function () {
|
||||
self.emit("reconnecting", "delay " + self.retry_delay + ", attempt " + self.attempts);
|
||||
self.retry_timer = setTimeout(function () {
|
||||
if (exports.debug_mode) {
|
||||
console.log("Retrying conneciton...");
|
||||
console.log("Retrying connection...");
|
||||
}
|
||||
self.retry_delay = self.retry_delay * self.retry_backoff;
|
||||
self.stream.destroy();
|
||||
|
12
test.js
12
test.js
@@ -374,11 +374,18 @@ function run_next_test() {
|
||||
}
|
||||
}
|
||||
|
||||
var connected = false;
|
||||
var ended = false;
|
||||
client.on("connect", function () {
|
||||
connected = true;
|
||||
console.log();
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
client.on('end', function() {
|
||||
ended = true;
|
||||
});
|
||||
|
||||
client.on("error", function (err) {
|
||||
console.log("Redis clent connection failed.");
|
||||
});
|
||||
@@ -390,3 +397,8 @@ client.on("reconnecting", function (msg) {
|
||||
process.on('uncaughtException', function (err) {
|
||||
console.log("Uncaught exception: " + err.stack);
|
||||
});
|
||||
|
||||
process.on('exit', function(code) {
|
||||
assert.equal(true, connected);
|
||||
assert.equal(true, ended);
|
||||
});
|
@@ -1,4 +1,4 @@
|
||||
var redis = require("redis"),
|
||||
var redis = require("./index"),
|
||||
client = redis.createClient();
|
||||
|
||||
redis.debug_mode = true;
|
||||
|
Reference in New Issue
Block a user