From f4ad37e13fc9f509f9aade5de16fcd775b809902 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Sun, 1 Dec 2024 09:13:28 +0200 Subject: [PATCH 1/6] make sure sentel is close on quit() --- src/clients/sentinel.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/clients/sentinel.ts b/src/clients/sentinel.ts index 4306e57..62a9c1d 100644 --- a/src/clients/sentinel.ts +++ b/src/clients/sentinel.ts @@ -19,6 +19,8 @@ function extractDetails(masters: Array>) { export class Sentinel extends Single { + private sentinelClient: SingleGraphConnection; + init(falkordb: FalkorDB): Promise { const redisOption = (this.client.options ?? {}) as TypedRedisClientOptions; return this.tryConnectSentinelServer(this.client, redisOption, falkordb); @@ -50,6 +52,9 @@ export class Sentinel extends Single { }; const realClient = createClient<{ falkordb: typeof commands }, RedisFunctions, RedisScripts>(serverOptions) + // Save sentinel client to quite on quit() + this.sentinelClient = client; + // Set original client as sentinel and server client as client this.client = realClient; @@ -78,5 +83,13 @@ export class Sentinel extends Single { }) .connect(); } + + async quit() { + await super.quit(); + if (this.sentinelClient) { + const reply = this.sentinelClient.quit(); + return reply.then(() => {}) + } + } } From 3fb3abf1b21f7b97f2d90b4659429ec1c20bdf8b Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Sun, 1 Dec 2024 09:17:10 +0200 Subject: [PATCH 2/6] fix build --- src/clients/sentinel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clients/sentinel.ts b/src/clients/sentinel.ts index 62a9c1d..677b2d4 100644 --- a/src/clients/sentinel.ts +++ b/src/clients/sentinel.ts @@ -19,7 +19,7 @@ function extractDetails(masters: Array>) { export class Sentinel extends Single { - private sentinelClient: SingleGraphConnection; + private sentinelClient: SingleGraphConnection | undefined; init(falkordb: FalkorDB): Promise { const redisOption = (this.client.options ?? {}) as TypedRedisClientOptions; From 3b8e1380e5fa20a9e4d03ccf06384d9fd427d742 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Sun, 1 Dec 2024 09:18:53 +0200 Subject: [PATCH 3/6] mark sentinelClient as uninitalized --- src/clients/sentinel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clients/sentinel.ts b/src/clients/sentinel.ts index 677b2d4..54d7a98 100644 --- a/src/clients/sentinel.ts +++ b/src/clients/sentinel.ts @@ -19,7 +19,7 @@ function extractDetails(masters: Array>) { export class Sentinel extends Single { - private sentinelClient: SingleGraphConnection | undefined; + private sentinelClient!: SingleGraphConnection; init(falkordb: FalkorDB): Promise { const redisOption = (this.client.options ?? {}) as TypedRedisClientOptions; From 9d383f4b9c368bb8342b28ba041d6a582c8ae8df Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Sun, 1 Dec 2024 09:22:44 +0200 Subject: [PATCH 4/6] update version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f644d0e..85dc2ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "falkordb", - "version": "6.2.3", + "version": "6.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "falkordb", - "version": "6.2.3", + "version": "6.2.4", "license": "MIT", "workspaces": [ "./packages/*" diff --git a/package.json b/package.json index 5751193..98ca626 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "falkordb", - "version": "6.2.3", + "version": "6.2.4", "description": "A FalkorDB javascript library", "license": "MIT", "main": "./dist/index.js", From f00c989db4d3a2ca3b97a84add91aa47e7ea830d Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Sun, 1 Dec 2024 10:00:37 +0200 Subject: [PATCH 5/6] fix typo --- src/clients/sentinel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clients/sentinel.ts b/src/clients/sentinel.ts index 54d7a98..1eb5181 100644 --- a/src/clients/sentinel.ts +++ b/src/clients/sentinel.ts @@ -52,7 +52,7 @@ export class Sentinel extends Single { }; const realClient = createClient<{ falkordb: typeof commands }, RedisFunctions, RedisScripts>(serverOptions) - // Save sentinel client to quite on quit() + // Save sentinel client to quit on quit() this.sentinelClient = client; // Set original client as sentinel and server client as client From 8532829a1818cc766e06a84be8ef7330e7715eed Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Sun, 1 Dec 2024 10:13:22 +0200 Subject: [PATCH 6/6] don't wait on the first quite, let them run in parallel --- src/clients/sentinel.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/clients/sentinel.ts b/src/clients/sentinel.ts index 1eb5181..baf38a0 100644 --- a/src/clients/sentinel.ts +++ b/src/clients/sentinel.ts @@ -85,11 +85,14 @@ export class Sentinel extends Single { } async quit() { - await super.quit(); + const promises = [ + super.quit() + ]; if (this.sentinelClient) { const reply = this.sentinelClient.quit(); - return reply.then(() => {}) + promises.push(reply.then(() => {})) } + return Promise.all(promises).then(() => {}); } }