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

expunge function does not call its callback if it is called after the end() call. #574

Open
Dzenly opened this issue Sep 22, 2016 · 2 comments

Comments

@Dzenly
Copy link

Dzenly commented Sep 22, 2016

Tested with imap.yandex.ru mail.

    imap = new Imap(imapConfig);

    var myExpunge = function () {
      console.log('HERE'); / ok.
      return new Bluebird(function (resolve, reject) {
          imap.expunge(function (err) {
          console.log('HERE1'); // Never meet if the mail box is empty.
          // My poor promise will never be resolved or rejected. :(
          if (err) {
            reject(err);
          }
          resolve(true);
        });
      })
    }

Such a behavior kills a normal flow of any async actions.

@mscdex
Copy link
Owner

mscdex commented Sep 22, 2016

Can you set debug: console.log in the config and show the relevant output for the EXPUNGE request so a test can be written?

@Dzenly
Copy link
Author

Dzenly commented Sep 22, 2016

Thank you, I found a glitch in my code. I used imap.expunge() after imap.end():

        imap.end();
        console.log('BEFORE EXPUNGE CALL');
        imap.expunge(function (err) {
        })

And had such a debug log (no any mention of expunge in the log):

...
=> 'A6 LOGOUT'
BEFORE EXPUNGE CALL
<= '* BYE IMAP4rev1 Server logging out'
<= 'A6 OK LOGOUT completed'
[connection] Ended
[connection] Closed

When I removed imap.end() before imap.expunge() - the callback started to invoke.

But, I think it is useful to invoke the callback with an error (or throw some exception) in similar case (invalid object state), and not just ignore such a call.
Without this it would be too hard to debug anything in async code.

@Dzenly Dzenly changed the title expunge function does not call its callback if there is no mails in the box. expunge function does not call its callback if it is called after the end() call. Sep 22, 2016
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

No branches or pull requests

2 participants