Skip to content

Conversation

@plusiv
Copy link
Contributor

@plusiv plusiv commented Dec 12, 2025

There's an intermittent panic that occurs because an IDLE writer was registered with a nil textproto.Conn; when SMTP appends a message, Folder.Append notifies IDLE writers and WriteNumMessages dereferences w.tpc, causing a nil-pointer panic. It only fails sometimes because the notification depends on timing, if no IDLE session is active or the writer has already been removed, no call happens. The fix is to construct idleWriter with the active connection (newIdleWriter(tpc *textproto.Conn)) so updates write through the IMAP connection.

This pull request refactors the handling of the idleWriter in the IMAP IDLE implementation to improve code clarity and correctness. The main updates include introducing a constructor for idleWriter, updating its instantiation, and fixing the format of the EXPUNGE response.

Refactoring and correctness improvements:

  • Added a newIdleWriter constructor function for idleWriter to encapsulate initialization logic and replaced the previous direct instantiation with this constructor in the handleIdle method. [1] [2]
  • Corrected the IMAP EXPUNGE response format in WriteExpunge to include the required * prefix, ensuring compliance with the IMAP protocol.

@marle3003 marle3003 merged commit c9a0eb8 into marle3003:main Dec 13, 2025
4 checks passed
@marle3003
Copy link
Owner

Thank you for your contribution and for submitting this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants