From 7c38bf2282440214165ca45d87c6bf5770a47b09 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 18 Jul 2025 16:48:34 -0700 Subject: [PATCH] presence: Dispose Presence object when store disposed I happened to notice this message getting printed repeatedly in the debug logs (reformatted a bit): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: NetworkException: HTTP request failed. Client is already closed. (ClientException: HTTP request failed. Client is already closed., uri=https://chat.zulip.org/api/v1/users/me/presence) #0 ApiConnection.send (package:zulip/api/core.dart:175) #1 Presence._maybePingAndRecordResponse (package:zulip/model/presence.dart:93) #2 Presence._poll (package:zulip/model/presence.dart:121) That'd be a symptom of an old Presence continuing to run its polling loop after the ApiConnection has been closed, which happens when the PerAccountStore is disposed. Looks like when we introduced Presence in 5d43df2be (#1619), we forgot to call its `dispose` method. Fix that now. The presence model doesn't currently have any tests. So rather than try to add a test for just this, we'll leave it as something to include when we write those tests, #1620. --- lib/model/store.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/model/store.dart b/lib/model/store.dart index 9973cbc33e..7b48147f12 100644 --- a/lib/model/store.dart +++ b/lib/model/store.dart @@ -878,6 +878,7 @@ class PerAccountStore extends PerAccountStoreBase with recentDmConversationsView.dispose(); unreads.dispose(); _messages.dispose(); + presence.dispose(); typingStatus.dispose(); typingNotifier.dispose(); updateMachine?.dispose();