Skip to content

feat: log the number of read/written bytes on IMAP stream read error #6924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

link2xt
Copy link
Collaborator

@link2xt link2xt commented Jun 18, 2025

LoggingStream is a wrapper for IMAP/SMTP/HTTP session streams. Originally I started building it with the idea to debug #6477 and similar issues where IMAP loop gets stuck with the hope that right before the loop gets stuck or even continuously there are socket errors like a read timeout that are not treated correctly.

This can later be expanded to collect the metrics in the database, display them in the connectivity view, but not in this PR. Same for logging the write or flush errors, I have not added it for now because they are less common.

@link2xt link2xt force-pushed the link2xt/logging-stream branch from 2893f40 to 8efff30 Compare June 26, 2025 18:53
@link2xt link2xt force-pushed the link2xt/logging-stream branch 3 times, most recently from 7ce86bd to f6df3ee Compare July 13, 2025 06:51
@link2xt
Copy link
Collaborator Author

link2xt commented Jul 13, 2025

First commit currently adds peer_addr method to SessionStream trait. I also created chatmail/async-imap#120 that may be useful to get access to SessionStream of IMAP session and then to peer_addr, e.g. to log it or add current address to connectivity view.

@link2xt link2xt force-pushed the link2xt/logging-stream branch 2 times, most recently from 01d9db2 to 5ca9bb1 Compare July 13, 2025 10:15
@link2xt
Copy link
Collaborator Author

link2xt commented Jul 13, 2025

Logs look like this:

Read error on stream a.b.c.d:993 after reading 98624 and writing 1074 bytes: timed out.
src/scheduler.rs:422: Failed inbox fetch_idle: fetch_move_delete: fetch_new_messages: fetch_many_msgs: Failed to process IMAP FETCH result: io: timed out: timed out.

Now right before the message about IMAP timeout we get a log message with the peer address and the number of read and written bytes.

@link2xt link2xt changed the title feat: add logging to streams feat: log the number of read/written bytes on IMAP stream read error Jul 13, 2025
@link2xt link2xt force-pushed the link2xt/logging-stream branch from 5ca9bb1 to 932a8e1 Compare July 13, 2025 10:45
@link2xt link2xt marked this pull request as ready for review July 13, 2025 11:08
@link2xt link2xt force-pushed the link2xt/logging-stream branch from 932a8e1 to ff537b8 Compare July 13, 2025 16:34
@link2xt link2xt requested review from Hocuri and iequidoo July 16, 2025 02:46
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.

1 participant