Skip to content

Commit 6598da5

Browse files
author
Ruben Bridgewater
committed
Indicate transmission errors
1 parent ff19663 commit 6598da5

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ RedisClient.prototype.create_stream = function () {
233233
self.on_error(err);
234234
});
235235

236-
this.stream.once('close', function () {
237-
self.connection_gone('close', new Error('Stream connection closed'));
236+
this.stream.once('close', function (hadError) {
237+
self.connection_gone('close', new Error('Stream connection closed' + (hadError ? ' because of a transmission error' : '')));
238238
});
239239

240240
this.stream.once('end', function () {

test/auth.spec.js

+8-13
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ describe("client authentication", function () {
115115
auth_pass: auth
116116
});
117117
client = redis.createClient.apply(null, args);
118-
client.on("ready", function () {
119-
return done();
120-
});
118+
client.on("ready", done);
121119
});
122120

123121
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 () {
128126
no_ready_check: true
129127
});
130128
client = redis.createClient.apply(null, args);
131-
client.on("ready", function () {
132-
done();
133-
});
129+
client.on("ready", done);
134130
});
135131

136132
it('allows auth to be provided post-hoc with auth method', function (done) {
@@ -139,25 +135,24 @@ describe("client authentication", function () {
139135
var args = config.configureClient(parser, ip);
140136
client = redis.createClient.apply(null, args);
141137
client.auth(auth);
142-
client.on("ready", function () {
143-
return done();
144-
});
138+
client.on("ready", done);
145139
});
146140

147141
it('reconnects with appropriate authentication', function (done) {
148142
if (helper.redisProcess().spawnFailed()) this.skip();
149143

150-
var readyCount = 0;
151144
client = redis.createClient.apply(null, args);
152145
client.auth(auth);
153146
client.on("ready", function () {
154-
readyCount++;
155-
if (readyCount === 1) {
147+
if (this.times_connected === 1) {
156148
client.stream.destroy();
157149
} else {
158-
return done();
150+
done();
159151
}
160152
});
153+
client.on('reconnecting', function (params) {
154+
assert.strictEqual(params.error.message, 'Stream connection closed');
155+
});
161156
});
162157

163158
it('should return an error if the password is not of type string and a callback has been provided', function (done) {

0 commit comments

Comments
 (0)