Skip to content

Conversation

@link2xt
Copy link
Collaborator

@link2xt link2xt commented Nov 4, 2023

This prevents accidentally going IDLE
when the last new message has arrived
while the folder was closed.
For example, this happened in some tests:

  1. INBOX is selected to fetch, move and delete messages.
  2. One of the messages is deleted.
  3. INBOX is closed to expunge the message.
  4. A new message arrives.
  5. INBOX is selected with (CONDSTORE) to sync flags.
  6. Delta Chat goes into IDLE without downloading the new message.

To determine that a new message has arrived
we need to notice that UIDNEXT has advanced when selecting the folder. However, some servers such as Winmail Pro Mail Server 5.1.0616 do not return UIDNEXT in response to SELECT command.

To avoid interdependencies with the code
SELECTing the folder and having to implement
STATUS fallback after each SELECT even when we
may not want to go IDLE due to interrupt or unsolicited EXISTS, we simply call STATUS unconditionally before IDLE.

Fixes #4926

This prevents accidentally going IDLE
when the last new message has arrived
while the folder was closed.
For example, this happened in some tests:
1. INBOX is selected to fetch, move and delete messages.
2. One of the messages is deleted.
3. INBOX is closed to expunge the message.
4. A new message arrives.
5. INBOX is selected with (CONDSTORE) to sync flags.
6. Delta Chat goes into IDLE without downloading the new message.

To determine that a new message has arrived
we need to notice that UIDNEXT has advanced when selecting the folder.
However, some servers such as Winmail Pro Mail Server 5.1.0616
do not return UIDNEXT in response to SELECT command.

To avoid interdependencies with the code
SELECTing the folder and having to implement
STATUS fallback after each SELECT even when we
may not want to go IDLE due to interrupt or unsolicited EXISTS,
we simply call STATUS unconditionally before IDLE.
@link2xt link2xt force-pushed the link2xt/check-uid-next-before-idle branch from 5913bc0 to 1e2d406 Compare November 5, 2023 00:11
return Ok((self, info));
}

if let Some(folder) = watch_folder.as_ref() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like that idle allows watch_folder to be None, but decided not to refactor in this PR.

@link2xt
Copy link
Collaborator Author

link2xt commented Nov 5, 2023

At least all the tests passed on a first try.
For comparison, #4928 without this fix failed one check (hanged in test_qr_join_chat_with_pending) and seems to be stuck in another.

Copy link
Contributor

@hpk42 hpk42 left a comment

Choose a reason for hiding this comment

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

sounds like a good approach to try, thanks for investigating the rabbit holes!

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.

IMAP client hangs in IMAP IDLE if SELECT consumed EXISTS response notifying about new messages

4 participants