Skip to content

fix: defer kitty debug-log Close#909

Merged
andrinoff merged 1 commit intofloatpane:masterfrom
SAY-5:fix/kitty-debug-log-defer-close-894
Apr 26, 2026
Merged

fix: defer kitty debug-log Close#909
andrinoff merged 1 commit intofloatpane:masterfrom
SAY-5:fix/kitty-debug-log-defer-close-894

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented Apr 24, 2026

What?

Wrap open/write/close of the DEBUG_KITTY_LOG file in fetcher/fetcher.go in a closure with defer f.Close() so the file descriptor is always released, even if WriteString panics or returns mid-call.

Why?

The original OpenFile -> WriteString -> Close sequence was inline. A panic (or any non-local exit) between OpenFile and Close leaked the descriptor. The long-lived getDebugIMAPWriter handle at fetcher.go:45 stays as-is (intentional, stored on the package-level debugIMAPFile).

Fixes #894.

Test plan

  • go build ./...
  • go vet ./fetcher/...

fetcher/fetcher.go opened the DEBUG_KITTY_LOG file and then called
f.WriteString / f.Close inline, so a panic between open and close
(or during WriteString) would leak the file descriptor. Wrap the
open-write-close in a closure with 'defer f.Close()' so the handle
always returns, even under panic.

Only the kitty-img debug branch is touched; the long-lived
getDebugIMAPWriter handle at line 45 is intentional and left alone.

Fixes floatpane#894

Signed-off-by: SAY-5 <[email protected]>
@SAY-5 SAY-5 requested a review from a team as a code owner April 24, 2026 21:03
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @SAY-5! Please fix the following issues with your PR:

  • Title: Is too long (64 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

@github-actions github-actions Bot added bug Something isn't working ci CI / build pipeline labels Apr 24, 2026
@SAY-5 SAY-5 changed the title fix(fetcher): defer debug-log Close() in kitty-img branch (#894) fix(fetcher): defer kitty debug-log Close Apr 25, 2026
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @SAY-5! Please fix the following issues with your PR:

  • Title: Is too long (41 characters). The PR title must be strictly under 40 characters.

@andrinoff andrinoff changed the title fix(fetcher): defer kitty debug-log Close fix: defer kitty debug-log Close Apr 26, 2026
@floatpanebot floatpanebot dismissed stale reviews from themself April 26, 2026 09:28

Formatting issues have been resolved. Thank you!

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 5f14523 into floatpane:master Apr 26, 2026
18 of 20 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 ci CI / build pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: IMAP debug logger Close() without defer risks leak on panic

3 participants