fix(mail): drain UidFetch channel on early error; clarify ParseHeaderOnly doc

If header/body parsing errored mid-fetch we returned without draining the
message channel, so the UidFetch goroutine could block on a full channel.
Both fetch paths now break, drain remaining messages, then read the done
error. Verified with the race detector.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-22 07:51:45 +01:00
parent 8379fddbb2
commit 5d2461ad94
2 changed files with 33 additions and 10 deletions
+3 -1
View File
@@ -95,7 +95,9 @@ func ParseMessage(uid uint32, raw []byte) (Message, error) {
return m, nil
}
// ParseHeaderOnly decodes headers and detects attachments without keeping bodies.
// ParseHeaderOnly parses a full RFC822 message (raw bytes) and returns only the
// Header, with HasAttachments set. For IMAP BODY[HEADER]-only bytes (no body),
// use ParseHeaderBytes instead, which avoids downloading the body entirely.
func ParseHeaderOnly(uid uint32, raw []byte) (Header, error) {
m, err := ParseMessage(uid, raw)
if err != nil {