You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Do not emit the broken mode twice if exec is called
Add more tests
This commit is contained in:
@@ -19,9 +19,7 @@ describe("on lost connection", function () {
|
||||
var calls = 0;
|
||||
|
||||
client.once('ready', function() {
|
||||
// Pretend that redis can't reconnect
|
||||
client.on_connect = client.on_error;
|
||||
client.stream.destroy();
|
||||
helper.killConnection(client);
|
||||
});
|
||||
|
||||
client.on("reconnecting", function (params) {
|
||||
@@ -40,16 +38,14 @@ describe("on lost connection", function () {
|
||||
|
||||
it("emit an error after max retry timeout and do not try to reconnect afterwards", function (done) {
|
||||
var connect_timeout = 1000; // in ms
|
||||
client = redis.createClient({
|
||||
var client = redis.createClient({
|
||||
parser: parser,
|
||||
connect_timeout: connect_timeout
|
||||
});
|
||||
var time = 0;
|
||||
|
||||
client.once('ready', function() {
|
||||
// Pretend that redis can't reconnect
|
||||
client.on_connect = client.on_error;
|
||||
client.stream.destroy();
|
||||
helper.killConnection(client);
|
||||
});
|
||||
|
||||
client.on("reconnecting", function (params) {
|
||||
@@ -66,6 +62,23 @@ describe("on lost connection", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("end connection while retry is still ongoing", function (done) {
|
||||
var connect_timeout = 1000; // in ms
|
||||
var client = redis.createClient({
|
||||
parser: parser,
|
||||
connect_timeout: connect_timeout
|
||||
});
|
||||
|
||||
client.once('ready', function() {
|
||||
helper.killConnection(client);
|
||||
});
|
||||
|
||||
client.on("reconnecting", function (params) {
|
||||
client.end();
|
||||
setTimeout(done, 100);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user