Make ClientProxy.pauseServices async and drop its completion block

`pauseServices` took a completion block only because it was historically
called from `deinit`, which can't await (the SE-0371 note). `deinit` now
stops the sync itself, so the sole remaining caller is the AppCoordinator,
which can await instead.

Make `pauseServices` async and update the AppCoordinator background-task
and lifecycle call sites to await it, calling the OS-facing completions
(endBackgroundTask / setTaskCompleted) afterwards. This also removes the
`MainActor.assumeIsolated` workaround — awaiting a @MainActor method hops
onto the main actor cleanly — and fixes a latent bug where a nil `self` in
the background app refresh expiration handler would skip setTaskCompleted.
This commit is contained in:
Stefan Ceriu
2026-06-15 12:49:46 +03:00
parent 04fd1bfd0e
commit 02b114d40b
4 changed files with 31 additions and 37 deletions
@@ -431,18 +431,14 @@ class ClientProxy: ClientProxyProtocol {
}
}
func pauseServices(completion: (() -> Void)?) {
func pauseServices() async {
MXLog.info("Pausing services")
if restartTask != nil {
restartTask = nil
}
let task = transitionServices(to: .suspended)
Task {
await task.value
completion?()
}
await transitionServices(to: .suspended).value
}
func expireSyncSessions() async {