From 1d8302c9db2a49c4875bd83d3c87fa05265d5400 Mon Sep 17 00:00:00 2001 From: Carl Hopf Date: Tue, 14 Mar 2023 16:37:13 +0000 Subject: [PATCH 1/6] `FT.CREATE` - set `FIRST_KEY_INDEX` to `1` (#2440) --- packages/search/lib/commands/CREATE.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/search/lib/commands/CREATE.ts b/packages/search/lib/commands/CREATE.ts index 21662c28d7..37e8c6fb11 100644 --- a/packages/search/lib/commands/CREATE.ts +++ b/packages/search/lib/commands/CREATE.ts @@ -1,6 +1,8 @@ import { pushOptionalVerdictArgument } from '@redis/client/dist/lib/commands/generic-transformers'; import { RedisSearchLanguages, PropertyName, RediSearchSchema, pushSchema } from '.'; +export const FIRST_KEY_INDEX = 1; + interface CreateOptions { ON?: 'HASH' | 'JSON'; PREFIX?: string | Array; From d65a641b2db96c6d63a2a51c43e823aba8256e28 Mon Sep 17 00:00:00 2001 From: Leibale Eidelman Date: Fri, 17 Mar 2023 09:52:30 -0400 Subject: [PATCH 2/6] revert 1d8302c9db2a49c4875bd83d3c87fa05265d5400 --- packages/search/lib/commands/CREATE.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/search/lib/commands/CREATE.ts b/packages/search/lib/commands/CREATE.ts index 37e8c6fb11..21662c28d7 100644 --- a/packages/search/lib/commands/CREATE.ts +++ b/packages/search/lib/commands/CREATE.ts @@ -1,8 +1,6 @@ import { pushOptionalVerdictArgument } from '@redis/client/dist/lib/commands/generic-transformers'; import { RedisSearchLanguages, PropertyName, RediSearchSchema, pushSchema } from '.'; -export const FIRST_KEY_INDEX = 1; - interface CreateOptions { ON?: 'HASH' | 'JSON'; PREFIX?: string | Array; From 9f2e27d07d4edf2d89d5cf79c432e60478f21fcf Mon Sep 17 00:00:00 2001 From: sorilove Date: Tue, 25 Apr 2023 01:41:30 +0900 Subject: [PATCH 3/6] Fixed a bug in the updateIsActive function (#2476) Missing PubSubType.SHARDED and duplicate comparison of PubSubType.CHANNELS when comparing listeners size in updateIsActive function --- packages/client/lib/client/pub-sub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/lib/client/pub-sub.ts b/packages/client/lib/client/pub-sub.ts index 8efc9d8a2e..a8a909e025 100644 --- a/packages/client/lib/client/pub-sub.ts +++ b/packages/client/lib/client/pub-sub.ts @@ -307,7 +307,7 @@ export class PubSub { this.#isActive = ( this.#listeners[PubSubType.CHANNELS].size !== 0 || this.#listeners[PubSubType.PATTERNS].size !== 0 || - this.#listeners[PubSubType.CHANNELS].size !== 0 || + this.#listeners[PubSubType.SHARDED].size !== 0 || this.#subscribing !== 0 ); } From c88dea6151e2b96fe901cf549bc8c43e6ccb969f Mon Sep 17 00:00:00 2001 From: Gady Date: Mon, 24 Apr 2023 19:41:44 +0300 Subject: [PATCH 4/6] Augment subpackages npm info (#2478) * augment subpackages npm info * some more keywords --------- Co-authored-by: Leibale Eidelman --- packages/bloom/package.json | 14 +++++++++++++- packages/client/package.json | 5 ++++- packages/graph/package.json | 14 +++++++++++++- packages/json/package.json | 14 +++++++++++++- packages/search/package.json | 14 +++++++++++++- packages/time-series/package.json | 14 +++++++++++++- 6 files changed, 69 insertions(+), 6 deletions(-) diff --git a/packages/bloom/package.json b/packages/bloom/package.json index d4eef193d8..d2e2c80806 100644 --- a/packages/bloom/package.json +++ b/packages/bloom/package.json @@ -25,5 +25,17 @@ "ts-node": "^10.9.1", "typedoc": "^0.23.25", "typescript": "^4.9.5" - } + }, + "repository": { + "type": "git", + "url": "git://github.com/redis/node-redis.git" + }, + "bugs": { + "url": "https://github.com/redis/node-redis/issues" + }, + "homepage": "https://github.com/redis/node-redis/tree/master/packages/bloom", + "keywords": [ + "redis", + "RedisBloom" + ] } diff --git a/packages/client/package.json b/packages/client/package.json index c342fce26f..5fde2a35ad 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -45,5 +45,8 @@ "bugs": { "url": "https://github.com/redis/node-redis/issues" }, - "homepage": "https://github.com/redis/node-redis/tree/master/packages/client" + "homepage": "https://github.com/redis/node-redis/tree/master/packages/client", + "keywords": [ + "redis" + ] } diff --git a/packages/graph/package.json b/packages/graph/package.json index 40ce8b7c56..bbd5dd778d 100644 --- a/packages/graph/package.json +++ b/packages/graph/package.json @@ -25,5 +25,17 @@ "ts-node": "^10.9.1", "typedoc": "^0.23.25", "typescript": "^4.9.5" - } + }, + "repository": { + "type": "git", + "url": "git://github.com/redis/node-redis.git" + }, + "bugs": { + "url": "https://github.com/redis/node-redis/issues" + }, + "homepage": "https://github.com/redis/node-redis/tree/master/packages/graph", + "keywords": [ + "redis", + "RedisGraph" + ] } diff --git a/packages/json/package.json b/packages/json/package.json index 6f4c468bfd..b2f0ec9dbe 100644 --- a/packages/json/package.json +++ b/packages/json/package.json @@ -25,5 +25,17 @@ "ts-node": "^10.9.1", "typedoc": "^0.23.25", "typescript": "^4.9.5" - } + }, + "repository": { + "type": "git", + "url": "git://github.com/redis/node-redis.git" + }, + "bugs": { + "url": "https://github.com/redis/node-redis/issues" + }, + "homepage": "https://github.com/redis/node-redis/tree/master/packages/json", + "keywords": [ + "redis", + "RedisJSON" + ] } diff --git a/packages/search/package.json b/packages/search/package.json index 684bfe1ff0..61154daa01 100644 --- a/packages/search/package.json +++ b/packages/search/package.json @@ -25,5 +25,17 @@ "ts-node": "^10.9.1", "typedoc": "^0.23.25", "typescript": "^4.9.5" - } + }, + "repository": { + "type": "git", + "url": "git://github.com/redis/node-redis.git" + }, + "bugs": { + "url": "https://github.com/redis/node-redis/issues" + }, + "homepage": "https://github.com/redis/node-redis/tree/master/packages/search", + "keywords": [ + "redis", + "RediSearch" + ] } diff --git a/packages/time-series/package.json b/packages/time-series/package.json index 1d6a184e5f..fffad02f62 100644 --- a/packages/time-series/package.json +++ b/packages/time-series/package.json @@ -25,5 +25,17 @@ "ts-node": "^10.9.1", "typedoc": "^0.23.25", "typescript": "^4.9.5" - } + }, + "repository": { + "type": "git", + "url": "git://github.com/redis/node-redis.git" + }, + "bugs": { + "url": "https://github.com/redis/node-redis/issues" + }, + "homepage": "https://github.com/redis/node-redis/tree/master/packages/time-series", + "keywords": [ + "redis", + "RedisTimeSeries" + ] } From e1658ba6efa138f9caadfcd60563dbb7372a6f56 Mon Sep 17 00:00:00 2001 From: Carl Hopf Date: Wed, 26 Apr 2023 18:56:04 +0200 Subject: [PATCH 5/6] fix cluster extractFirstKey skip commandOptions() passed to args (#2439) * cluster extractFirstKey skip commandOptions() passed to args * cluster with commandOptions unit test * improve performance * fix type * fix type --------- Co-authored-by: Leibale Eidelman --- packages/client/lib/cluster/index.spec.ts | 16 ++++++++++++++++ packages/client/lib/cluster/index.ts | 4 ++-- packages/client/lib/commander.ts | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/client/lib/cluster/index.spec.ts b/packages/client/lib/cluster/index.spec.ts index 6b9d35f75f..8200375056 100644 --- a/packages/client/lib/cluster/index.spec.ts +++ b/packages/client/lib/cluster/index.spec.ts @@ -2,6 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils'; import RedisCluster from '.'; import { ClusterSlotStates } from '../commands/CLUSTER_SETSLOT'; +import { commandOptions } from '../command-options'; import { SQUARE_SCRIPT } from '../client/index.spec'; import { RootNodesUnavailableError } from '../errors'; import { spy } from 'sinon'; @@ -178,6 +179,21 @@ describe('Cluster', () => { await assert.rejects(cluster.mGet(['a', 'b'])); }, GLOBAL.CLUSTERS.OPEN); + testUtils.testWithCluster('should send commands with commandOptions to correct cluster slot (without redirections)', async cluster => { + // 'a' and 'b' hash to different cluster slots (see previous unit test) + // -> maxCommandRedirections 0: rejects on MOVED/ASK reply + await cluster.set(commandOptions({ isolated: true }), 'a', '1'), + await cluster.set(commandOptions({ isolated: true }), 'b', '2'), + + assert.equal(await cluster.get('a'), '1'); + assert.equal(await cluster.get('b'), '2'); + }, { + ...GLOBAL.CLUSTERS.OPEN, + clusterConfiguration: { + maxCommandRedirections: 0 + } + }); + describe('minimizeConnections', () => { testUtils.testWithCluster('false', async cluster => { for (const master of cluster.masters) { diff --git a/packages/client/lib/cluster/index.ts b/packages/client/lib/cluster/index.ts index 818930c8c8..7e486a376b 100644 --- a/packages/client/lib/cluster/index.ts +++ b/packages/client/lib/cluster/index.ts @@ -152,11 +152,11 @@ export default class RedisCluster< command: C, args: Array ): Promise> { - const { args: redisArgs, options } = transformCommandArguments(command, args); + const { jsArgs, args: redisArgs, options } = transformCommandArguments(command, args); return transformCommandReply( command, await this.sendCommand( - RedisCluster.extractFirstKey(command, args, redisArgs), + RedisCluster.extractFirstKey(command, jsArgs, redisArgs), command.IS_READ_ONLY, redisArgs, options diff --git a/packages/client/lib/commander.ts b/packages/client/lib/commander.ts index 1407a80344..c04f41e1eb 100644 --- a/packages/client/lib/commander.ts +++ b/packages/client/lib/commander.ts @@ -108,6 +108,7 @@ export function transformCommandArguments( command: RedisCommand, args: Array ): { + jsArgs: Array; args: RedisCommandArguments; options: CommandOptions | undefined; } { @@ -118,6 +119,7 @@ export function transformCommandArguments( } return { + jsArgs: args, args: command.transformArguments(...args), options }; From ba31c8a50e73bd19825f3eb779270343c0fff205 Mon Sep 17 00:00:00 2001 From: Leibale Eidelman Date: Wed, 26 Apr 2023 12:56:42 -0400 Subject: [PATCH 6/6] fix #2443 - fix multiple sockets on error in socket initiator (#2480) * fix #2443 - fix multiple sockets on error in socket initiator * handle `error` events in test --- packages/client/lib/client/index.spec.ts | 3 +++ packages/client/lib/client/socket.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/client/lib/client/index.spec.ts b/packages/client/lib/client/index.spec.ts index 7396a2e9c3..b608c7c092 100644 --- a/packages/client/lib/client/index.spec.ts +++ b/packages/client/lib/client/index.spec.ts @@ -647,6 +647,9 @@ describe('Client', () => { }); testUtils.testWithClient('should propagated errors from "isolated" clients', client => { + client.on('error', () => { + // ignore errors + }); return client.executeIsolated(isolated => killClient(isolated, client)); }, GLOBAL.SERVERS.OPEN); diff --git a/packages/client/lib/client/socket.ts b/packages/client/lib/client/socket.ts index ac3b7f5bf3..89533350f5 100644 --- a/packages/client/lib/client/socket.ts +++ b/packages/client/lib/client/socket.ts @@ -199,7 +199,7 @@ export default class RedisSocket extends EventEmitter { .off('error', reject) .once('error', (err: Error) => this.#onSocketError(err)) .once('close', hadError => { - if (!hadError && this.#isOpen && this.#socket === socket) { + if (!hadError && this.#isReady && this.#socket === socket) { this.#onSocketError(new SocketClosedUnexpectedlyError()); } })