From 4d0c9172e57fd62519c4293ebce55be0a968becd Mon Sep 17 00:00:00 2001 From: Brandon Wees Date: Mon, 4 Aug 2025 17:14:26 -0500 Subject: [PATCH] fix: not clearing local data when logging out while sync is running (#20646) --- mobile/lib/domain/utils/background_sync.dart | 8 ++++++-- mobile/lib/main.dart | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mobile/lib/domain/utils/background_sync.dart b/mobile/lib/domain/utils/background_sync.dart index 1944591c93..cbf4030788 100644 --- a/mobile/lib/domain/utils/background_sync.dart +++ b/mobile/lib/domain/utils/background_sync.dart @@ -37,7 +37,7 @@ class BackgroundSyncManager { this.onHashingError, }); - Future cancel() { + Future cancel() async { final futures = []; if (_syncTask != null) { @@ -52,7 +52,11 @@ class BackgroundSyncManager { _syncWebsocketTask?.cancel(); _syncWebsocketTask = null; - return Future.wait(futures); + try { + await Future.wait(futures); + } on CanceledError { + // Ignore cancellation errors + } } // No need to cancel the task, as it can also be run when the user logs out diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart index d1f415a304..0bac282694 100644 --- a/mobile/lib/main.dart +++ b/mobile/lib/main.dart @@ -83,7 +83,6 @@ Future initApp() async { }; PlatformDispatcher.instance.onError = (error, stack) { - debugPrint("FlutterError - Catch all: $error \n $stack"); log.severe('PlatformDispatcher - Catch all', error, stack); return true; };