1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Indicate transmission errors

This commit is contained in:
Ruben Bridgewater
2016-03-14 22:55:01 +01:00
parent ff19663d9d
commit 6598da5366
2 changed files with 10 additions and 15 deletions

View File

@@ -233,8 +233,8 @@ RedisClient.prototype.create_stream = function () {
self.on_error(err);
});
this.stream.once('close', function () {
self.connection_gone('close', new Error('Stream connection closed'));
this.stream.once('close', function (hadError) {
self.connection_gone('close', new Error('Stream connection closed' + (hadError ? ' because of a transmission error' : '')));
});
this.stream.once('end', function () {

View File

@@ -115,9 +115,7 @@ describe("client authentication", function () {
auth_pass: auth
});
client = redis.createClient.apply(null, args);
client.on("ready", function () {
return done();
});
client.on("ready", done);
});
it('allows auth and no_ready_check to be provided as config option for client', function (done) {
@@ -128,9 +126,7 @@ describe("client authentication", function () {
no_ready_check: true
});
client = redis.createClient.apply(null, args);
client.on("ready", function () {
done();
});
client.on("ready", done);
});
it('allows auth to be provided post-hoc with auth method', function (done) {
@@ -139,25 +135,24 @@ describe("client authentication", function () {
var args = config.configureClient(parser, ip);
client = redis.createClient.apply(null, args);
client.auth(auth);
client.on("ready", function () {
return done();
});
client.on("ready", done);
});
it('reconnects with appropriate authentication', function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
var readyCount = 0;
client = redis.createClient.apply(null, args);
client.auth(auth);
client.on("ready", function () {
readyCount++;
if (readyCount === 1) {
if (this.times_connected === 1) {
client.stream.destroy();
} else {
return done();
done();
}
});
client.on('reconnecting', function (params) {
assert.strictEqual(params.error.message, 'Stream connection closed');
});
});
it('should return an error if the password is not of type string and a callback has been provided', function (done) {