fix offline: remove deadlocking syncShutdownGracefully from deinit, limit flag sync range

- remove deinit from IMAPConnection, SMTPConnection — syncShutdownGracefully
  blocks and deadlocks if called on NIO event loop thread
- limit reconcileFlags to last 500 UIDs to avoid overwhelming the connection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-15 11:44:45 +01:00
parent d5eaf35665
commit 1e39a2bd43
3 changed files with 3 additions and 10 deletions

View File

@@ -17,10 +17,6 @@ actor IMAPConnection {
self.responseHandler = IMAPResponseHandler()
}
deinit {
try? group.syncShutdownGracefully()
}
func connect() async throws {
let sslContext = try NIOSSLContext(configuration: TLSConfiguration.makeClientConfiguration())
let handler = responseHandler

View File

@@ -19,10 +19,6 @@ actor SMTPConnection {
self.responseHandler = SMTPResponseHandler()
}
deinit {
try? group.syncShutdownGracefully()
}
func connect() async throws -> SMTPResponse {
let handler = responseHandler
let hostname = host

View File

@@ -171,9 +171,10 @@ public final class SyncCoordinator {
emit(.newMessages(count: envelopes.count, mailbox: remoteMailbox.name))
}
// Reconcile flags for existing messages (read/unread state from other devices)
// Reconcile flags for recent existing messages (read/unread state from other devices)
if lastUid > 0 {
await reconcileFlags(mailboxId: mailboxId, uidRange: 1...lastUid)
let flagSyncStart = max(1, lastUid - 499)
await reconcileFlags(mailboxId: mailboxId, uidRange: flagSyncStart...lastUid)
}
await prefetchBodies(mailboxId: mailboxId)