You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
fix for e11256854e
- should not retry connecting if failed due to wrong auth
This commit is contained in:
@@ -11,7 +11,7 @@ import { ScanCommandOptions } from '../commands/SCAN';
|
|||||||
import { HScanTuple } from '../commands/HSCAN';
|
import { HScanTuple } from '../commands/HSCAN';
|
||||||
import { extendWithCommands, extendWithModulesAndScripts, LegacyCommandArguments, transformCommandArguments, transformCommandReply, transformLegacyCommandArguments } from '../commander';
|
import { extendWithCommands, extendWithModulesAndScripts, LegacyCommandArguments, transformCommandArguments, transformCommandReply, transformLegacyCommandArguments } from '../commander';
|
||||||
import { Pool, Options as PoolOptions, createPool } from 'generic-pool';
|
import { Pool, Options as PoolOptions, createPool } from 'generic-pool';
|
||||||
import { ClientClosedError, DisconnectsClientError } from '../errors';
|
import { ClientClosedError, DisconnectsClientError, AuthError } from '../errors';
|
||||||
import { URL } from 'url';
|
import { URL } from 'url';
|
||||||
import { TcpSocketConnectOpts } from 'net';
|
import { TcpSocketConnectOpts } from 'net';
|
||||||
|
|
||||||
@@ -219,7 +219,9 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
|||||||
password: this.#options.password ?? ''
|
password: this.#options.password ?? ''
|
||||||
}),
|
}),
|
||||||
{ asap: true }
|
{ asap: true }
|
||||||
)
|
).catch(err => {
|
||||||
|
throw new AuthError(err.message);
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@ import * as net from 'net';
|
|||||||
import * as tls from 'tls';
|
import * as tls from 'tls';
|
||||||
import { encodeCommand } from '../commander';
|
import { encodeCommand } from '../commander';
|
||||||
import { RedisCommandArguments } from '../commands';
|
import { RedisCommandArguments } from '../commands';
|
||||||
import { ConnectionTimeoutError, ClientClosedError, SocketClosedUnexpectedlyError } from '../errors';
|
import { ConnectionTimeoutError, ClientClosedError, SocketClosedUnexpectedlyError, AuthError } from '../errors';
|
||||||
import { promiseTimeout } from '../utils';
|
import { promiseTimeout } from '../utils';
|
||||||
|
|
||||||
export interface RedisSocketCommonOptions {
|
export interface RedisSocketCommonOptions {
|
||||||
@@ -110,6 +110,11 @@ export default class RedisSocket extends EventEmitter {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.#socket.destroy();
|
this.#socket.destroy();
|
||||||
this.#socket = undefined;
|
this.#socket = undefined;
|
||||||
|
|
||||||
|
if (err instanceof AuthError) {
|
||||||
|
this.#isOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,3 +33,9 @@ export class SocketClosedUnexpectedlyError extends Error {
|
|||||||
super('Socket closed unexpectedly');
|
super('Socket closed unexpectedly');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class AuthError extends Error {
|
||||||
|
constructor(message: string) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user