Skip to content

fix(imap): close debug log file handle to prevent fd leak#525

Merged
andrinoff merged 2 commits into
floatpane:masterfrom
sueun-dev:master
Apr 15, 2026
Merged

fix(imap): close debug log file handle to prevent fd leak#525
andrinoff merged 2 commits into
floatpane:masterfrom
sueun-dev:master

Conversation

@sueun-dev
Copy link
Copy Markdown
Contributor

Fixes #504

connectWithOptions() was opening a new debug log file handle every time an IMAP connection was created when DEBUG_IMAP is set, but never closing it. over time this leaks a file descriptor per connection (fetches, IDLE reconnects, etc).

moved the os.OpenFile call into a sync.Once so theres one shared handle for the entire process lifetime. the helper getDebugIMAPWriter() returns the cached io.Writer or nil if the env var isnt set.

pretty straightforward fix, lmk if theres anything I missed

Fixes floatpane#504\n\nconnectWithOptions() was opening a new file handle for DEBUG_IMAP on every connection but never closing it, leaking a fd each time. moved the open into a sync.Once so theres one shared handle for the process lifetime.
@sueun-dev sueun-dev requested a review from a team as a code owner April 15, 2026 20:15
@github-actions github-actions Bot added the bug Something isn't working label Apr 15, 2026
@andrinoff
Copy link
Copy Markdown
Member

@sueun-dev thank you for your contribution!

Please, run make lint and commit the changes. Workflow is failing

Signed-off-by: drew <me@andrinoff.com>
Copy link
Copy Markdown
Member

@andrinoff andrinoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@andrinoff andrinoff merged commit 98b5a32 into floatpane:master Apr 15, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Debug IMAP file handle leak

2 participants