Skip to content

Commit 4f7f1ad

Browse files
committed
fix: silence auth errors on reconnect
1 parent 42e8bd6 commit 4f7f1ad

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

index.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ function create_parser (self) {
228228
RedisClient.prototype.create_stream = function () {
229229
var self = this;
230230

231-
var first_attempt = !this.stream;
232-
233231
// Init parser
234232
this.reply_parser = create_parser(this);
235233

@@ -308,8 +306,7 @@ RedisClient.prototype.create_stream = function () {
308306
this.ready = true;
309307
// Fail silently as we might not be able to connect
310308
this.auth(this.auth_pass, function (err) {
311-
if (err && first_attempt) {
312-
self.command_queue.get(0).callback = noop;
309+
if (err && err.code !== 'UNCERTAIN_STATE') {
313310
self.emit('error', err);
314311
}
315312
});

test/auth.spec.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,9 @@ describe('client authentication', function () {
260260
password: 'wrong_password',
261261
parser: parser
262262
});
263-
client.on('error', function (err) {
263+
client.once('error', function (err) {
264264
assert.strictEqual(err.message, 'ERR invalid password');
265-
// Make sure no other errors are reported
266-
setTimeout(done, 50);
265+
done();
267266
});
268267
});
269268

0 commit comments

Comments
 (0)