Describe the bug
In fetcher/fetcher.go, when the DEBUG_IMAP environment variable is set, a file is opened for debug logging but never closed. Each IMAP connection leaks a file descriptor.
if path := os.Getenv("DEBUG_IMAP"); path != "" {
if f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600); err == nil {
options.DebugWriter = f
}
}
The file f is never closed — there is no defer f.Close() and no tracking of the handle for later cleanup.
To reproduce
- Set
DEBUG_IMAP=/tmp/imap.log
- Run matcha and let it make multiple IMAP connections (e.g. fetch emails, IDLE reconnects)
- Observe file descriptor count growing via
ls /proc/<pid>/fd | wc -l
Expected behavior
The debug log file handle should be properly closed when the IMAP connection is closed, or a single shared file handle should be reused across connections.
OS
All platforms
Describe the bug
In
fetcher/fetcher.go, when theDEBUG_IMAPenvironment variable is set, a file is opened for debug logging but never closed. Each IMAP connection leaks a file descriptor.The file
fis never closed — there is nodefer f.Close()and no tracking of the handle for later cleanup.To reproduce
DEBUG_IMAP=/tmp/imap.logls /proc/<pid>/fd | wc -lExpected behavior
The debug log file handle should be properly closed when the IMAP connection is closed, or a single shared file handle should be reused across connections.
OS
All platforms