From 2ae9e500a41e9760e3149b2ddf890539b953b0da Mon Sep 17 00:00:00 2001 From: martincupela Date: Tue, 29 Oct 2024 16:33:04 +0100 Subject: [PATCH 1/2] fix: remove rejected channel query promises from channel query lock --- src/utils/getChannel.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils/getChannel.ts b/src/utils/getChannel.ts index 00962c5711..d94b1c1a7e 100644 --- a/src/utils/getChannel.ts +++ b/src/utils/getChannel.ts @@ -68,9 +68,14 @@ export const getChannel = async < if (queryPromise) { await queryPromise; } else { - WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch(options); - await WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]; - delete WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]; + try { + WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch(options); + await WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]; + delete WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]; + } catch (e) { + delete WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]; + throw e; + } } return theChannel; From e2519de66513a266188a5f6b2969b98e573772c9 Mon Sep 17 00:00:00 2001 From: martincupela Date: Tue, 29 Oct 2024 16:43:28 +0100 Subject: [PATCH 2/2] refactor: simplify error handling --- src/utils/getChannel.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/getChannel.ts b/src/utils/getChannel.ts index d94b1c1a7e..d47784ada6 100644 --- a/src/utils/getChannel.ts +++ b/src/utils/getChannel.ts @@ -71,10 +71,8 @@ export const getChannel = async < try { WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch(options); await WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]; + } finally { delete WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]; - } catch (e) { - delete WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]; - throw e; } }