From 353d9ef16e1c4e1911838f15ccf9b653ed48eaa7 Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Tue, 12 May 2026 00:59:05 -0700 Subject: [PATCH] fix: mailbox channel send non-blocking (#1270) --- fetcher/idle.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fetcher/idle.go b/fetcher/idle.go index a2fc0fbde0321b5f8d12f508f8385ef495fae650..cb8c60fa3c8e356471c123b5bb2b90fd1cb9c133 100644 --- a/fetcher/idle.go +++ b/fetcher/idle.go @@ -158,8 +158,17 @@ func (a *accountIdle) idleOnce() error { mailboxUpdates := make(chan uint32, 32) c, err := connectWithHandler(a.account, &imapclient.UnilateralDataHandler{ Mailbox: func(data *imapclient.UnilateralDataMailbox) { - if data.NumMessages != nil { - mailboxUpdates <- *data.NumMessages + if data.NumMessages == nil { + return + } + // Non-blocking send: the callback runs on the IMAP socket-reader + // goroutine, so a synchronous send would stall the socket if the + // channel is full. The consumer only acts on the latest count + // (see prevExists tracking below), so dropping a stale update is + // safe — the next update will deliver the current count. + select { + case mailboxUpdates <- *data.NumMessages: + default: } }, })