Skip to content
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

IdleManager.watch() returns before IDLE state is established #159

Open
brr53 opened this issue Nov 27, 2024 · 0 comments
Open

IdleManager.watch() returns before IDLE state is established #159

brr53 opened this issue Nov 27, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@brr53
Copy link

brr53 commented Nov 27, 2024

Current Behavior

The IdleManager.watch(folder) method returns immediately after queuing the folder for IDLE monitoring, before the IDLE state is actually established. This makes it impossible to know when the IMAP IDLE connection is ready to receive messages.

Debug logs show this sequence:

DEBUG IMAP: IdleManager.watch startIdle succeeded for imaps://%[email protected]/INBOX // watch() returns here
DEBUG IMAP: IdleManager selected 0 channels
DEBUG IMAP: IdleManager adding imaps://%[email protected]/INBOX to selector
DEBUG IMAP: IdleManager waiting... // IDLE is actually ready here.

It is easy to make the mistake of thinking IDLE is ready when it isn't as watch() succeeds prematurely.
We understand the reasoning on why watch() exits prematurely - it is due to the executor running in parallel however we must be able to wait for IDLE to succeed before continuing.

Expected Behavior

One of these options:

  1. watch() should wait until IDLE is fully established
  2. Add a new method like watchAndWait() that blocks until IDLE is ready
  3. Expose a way to query/listen for the IDLE ready state

Use Case

When setting up IMAP IDLE monitoring, applications need to know when the connection is actually ready to receive messages. Currently there's no clean way to detect this without resorting to implementation details or log parsing.

Mail server:

It is an issue with the angus-mail itself and not the mail server.

  • Protocol being used: imap
  • Mail service URL: gmail.com

Additional context
Currently, it appears the only way to wait for an IDLE state to be ready is via "hacks".

@jmehrens jmehrens added the enhancement New feature or request label Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants