From bde749dc6be5041b5df915040efa66abd28ee450 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 15 Apr 2024 06:46:57 +0545 Subject: [PATCH 1/2] close realtime socket properly on unsubscribe --- templates/web/src/client.ts.twig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/web/src/client.ts.twig b/templates/web/src/client.ts.twig index f952c31c2..65f8bb296 100644 --- a/templates/web/src/client.ts.twig +++ b/templates/web/src/client.ts.twig @@ -186,7 +186,11 @@ class Client { } }, createSocket: () => { - if (this.realtime.channels.size < 1) return; + if (this.realtime.channels.size < 1) { + this.realtime.reconnect = false; + this.realtime.socket.close(); + return; + } const channels = new URLSearchParams(); channels.set('project', this.config.project); From 421564a12a41cdd36c5187d170417c229574109f Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 15 Apr 2024 01:24:08 +0000 Subject: [PATCH 2/2] fix close --- templates/web/src/client.ts.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/web/src/client.ts.twig b/templates/web/src/client.ts.twig index 65f8bb296..19ca21691 100644 --- a/templates/web/src/client.ts.twig +++ b/templates/web/src/client.ts.twig @@ -188,7 +188,7 @@ class Client { createSocket: () => { if (this.realtime.channels.size < 1) { this.realtime.reconnect = false; - this.realtime.socket.close(); + this.realtime.socket?.close(); return; }