From 830199e2407faa1c08eb7e3fb0bf7423a4267747 Mon Sep 17 00:00:00 2001 From: roggervalf Date: Wed, 6 Nov 2024 20:08:41 -0500 Subject: [PATCH] fix(connection): set verson as protected attribute for extension --- src/classes/redis-connection.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/classes/redis-connection.ts b/src/classes/redis-connection.ts index 580d8db3b2..08cf4472ea 100644 --- a/src/classes/redis-connection.ts +++ b/src/classes/redis-connection.ts @@ -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 = [ @@ -52,6 +52,7 @@ export class RedisConnection extends EventEmitter { private readonly initializing: Promise; private version: string; + protected packageVersion: string; private skipVersionCheck: boolean; private handleClientError: (e: Error) => void; private handleClientClose: () => void; @@ -64,7 +65,7 @@ export class RedisConnection extends EventEmitter { skipVersionCheck = false, ) { super(); - + this.packageVersion = packageVersion; if (!isRedisInstance(opts)) { this.checkBlockingOptions(overrideMessage, opts); @@ -197,14 +198,14 @@ export class RedisConnection extends EventEmitter { } protected loadCommands( - version: string, + packageVersion: string, providedScripts?: Record, ): void { const finalScripts = providedScripts || (scripts as Record); for (const property in finalScripts as Record) { // Only define the command if not already defined - const commandName = `${finalScripts[property].name}:${version}`; + const commandName = `${finalScripts[property].name}:${packageVersion}`; if (!(this._client)[commandName]) { (this._client).defineCommand(commandName, { numberOfKeys: finalScripts[property].keys, @@ -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();