Explorar o código

Fix account sync race condition

nimbleghost %!s(int64=2) %!d(string=hai) anos
pai
achega
453bf435b0
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      web/src/components/hooks.js

+ 7 - 0
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 {