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:
@@ -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
|
||||
|
||||
@@ -19,10 +19,6 @@ actor SMTPConnection {
|
||||
self.responseHandler = SMTPResponseHandler()
|
||||
}
|
||||
|
||||
deinit {
|
||||
try? group.syncShutdownGracefully()
|
||||
}
|
||||
|
||||
func connect() async throws -> SMTPResponse {
|
||||
let handler = responseHandler
|
||||
let hostname = host
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user