From 08db97199a1ca25897aad58273035eaf41bbb52b Mon Sep 17 00:00:00 2001 From: Salem Mohammed Shamakh <58360393+salemkode@users.noreply.github.com> Date: Thu, 28 Aug 2025 15:13:48 +0300 Subject: [PATCH] fix(convex-query-client): prevent crash when unsubscribing missing query subscription --- src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index b08a18d..e3374fe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -259,8 +259,11 @@ export class ConvexQueryClient { // A query has been GC'd so no stale value will be available. // In Convex this means we should unsubscribe. case "removed": { - this.subscriptions[event.query.queryHash].unsubscribe(); - delete this.subscriptions[event.query.queryHash]; + const subscription = this.subscriptions[event.query.queryHash]; + if (subscription) { + subscription.unsubscribe(); + delete this.subscriptions[event.query.queryHash]; + } break; } // A query has been requested for the first time.