From 453bf435b0be9f8ed459e4fb43abbb87eb6d1f64 Mon Sep 17 00:00:00 2001 From: nimbleghost <132819643+nimbleghost@users.noreply.github.com> Date: Wed, 31 May 2023 18:55:17 +0200 Subject: [PATCH] Fix account sync race condition --- web/src/components/hooks.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/src/components/hooks.js b/web/src/components/hooks.js index b9c5536..6b68188 100644 --- a/web/src/components/hooks.js +++ b/web/src/components/hooks.js @@ -47,6 +47,13 @@ export const useConnectionListeners = (account, subscriptions, users) => { const handleMessage = async (subscriptionId, message) => { const subscription = await subscriptionManager.get(subscriptionId); + + // Race condition: sometimes the subscription is already unsubscribed from account + // sync before the message is handled + if (!subscription) { + return; + } + if (subscription.internal) { await handleInternalMessage(message); } else {