Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(connection): set version as protected attribute for extension #2884

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/classes/redis-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
isRedisInstance,
isRedisVersionLowerThan,
} from '../utils';
import { version } from '../version';
import { version as packageVersion } from '../version';
import * as scripts from '../scripts';

const overrideMessage = [
Expand Down Expand Up @@ -52,6 +52,7 @@ export class RedisConnection extends EventEmitter {
private readonly initializing: Promise<RedisClient>;

private version: string;
protected packageVersion: string;
private skipVersionCheck: boolean;
private handleClientError: (e: Error) => void;
private handleClientClose: () => void;
Expand All @@ -64,7 +65,7 @@ export class RedisConnection extends EventEmitter {
skipVersionCheck = false,
) {
super();

this.packageVersion = packageVersion;
if (!isRedisInstance(opts)) {
this.checkBlockingOptions(overrideMessage, opts);

Expand Down Expand Up @@ -197,14 +198,14 @@ export class RedisConnection extends EventEmitter {
}

protected loadCommands(
version: string,
packageVersion: string,
providedScripts?: Record<string, RawCommand>,
): void {
const finalScripts =
providedScripts || (scripts as Record<string, RawCommand>);
for (const property in finalScripts as Record<string, RawCommand>) {
// Only define the command if not already defined
const commandName = `${finalScripts[property].name}:${version}`;
const commandName = `${finalScripts[property].name}:${packageVersion}`;
if (!(<any>this._client)[commandName]) {
(<any>this._client).defineCommand(commandName, {
numberOfKeys: finalScripts[property].keys,
Expand All @@ -230,7 +231,7 @@ export class RedisConnection extends EventEmitter {

await RedisConnection.waitUntilReady(this._client);

this.loadCommands(version);
this.loadCommands(this.packageVersion);

if (this._client['status'] !== 'end') {
this.version = await this.getRedisVersion();
Expand Down
Loading