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

fix socket error handlers (#2092)

* fix socket error handlers, reset parser on error

* fix #2080 - reset pubSubState on socket error

* fix pubsub

* fix "RedisSocketInitiator"
This commit is contained in:
Leibale Eidelman
2022-04-25 05:47:51 -04:00
committed by GitHub
parent 8b5a5473a4
commit e6de453fdd
6 changed files with 72 additions and 146 deletions

View File

@@ -3,7 +3,7 @@ import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils';
import RedisClient, { RedisClientType } from '.';
import { RedisClientMultiCommandType } from './multi-command';
import { RedisCommandArguments, RedisCommandRawReply, RedisModules, RedisScripts } from '../commands';
import { AbortError, AuthError, ClientClosedError, ConnectionTimeoutError, DisconnectsClientError, SocketClosedUnexpectedlyError, WatchError } from '../errors';
import { AbortError, ClientClosedError, ConnectionTimeoutError, DisconnectsClientError, SocketClosedUnexpectedlyError, WatchError } from '../errors';
import { defineScript } from '../lua-script';
import { spy } from 'sinon';
import { once } from 'events';
@@ -87,30 +87,6 @@ describe('Client', () => {
);
}, GLOBAL.SERVERS.PASSWORD);
testUtils.testWithClient('should not retry connecting if failed due to wrong auth', async client => {
let message;
if (testUtils.isVersionGreaterThan([6, 2])) {
message = 'WRONGPASS invalid username-password pair or user is disabled.';
} else if (testUtils.isVersionGreaterThan([6])) {
message = 'WRONGPASS invalid username-password pair';
} else {
message = 'ERR invalid password';
}
await assert.rejects(
client.connect(),
new AuthError(message)
);
assert.equal(client.isOpen, false);
}, {
...GLOBAL.SERVERS.PASSWORD,
clientOptions: {
password: 'wrongpassword'
},
disableClientSetup: true
});
testUtils.testWithClient('should execute AUTH before SELECT', async client => {
assert.equal(
(await client.clientInfo()).db,
@@ -300,7 +276,8 @@ describe('Client', () => {
await client.multi()
.sAdd('a', ['b', 'c'])
.v4.exec(),
[2])
[2]
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
@@ -681,10 +658,6 @@ describe('Client', () => {
const listener = spy();
await subscriber.subscribe('channel', listener);
subscriber.on('error', err => {
console.error('subscriber err', err.message);
});
await Promise.all([
once(subscriber, 'error'),
publisher.clientKill({