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

Connection not closing after getBoxes execution. #895

Open
martinericksonn opened this issue Jan 25, 2023 · 0 comments
Open

Connection not closing after getBoxes execution. #895

martinericksonn opened this issue Jan 25, 2023 · 0 comments

Comments

@martinericksonn
Copy link

martinericksonn commented Jan 25, 2023

Supposed after executing getBoxes() the connection will end thus log connection ended but instead is stuck after logging all the key

      const connection = new Imap(credential);

        let folders = [];

        connection.once("ready", () => {
          connection.getBoxes(function more(err, boxes, path) {
            if (err) throw err;

            for (var key in boxes) {
              if (boxes[key].children)
                more(
                  undefined,
                  boxes[key].children,
                  path + key + boxes[key].delimiter
                );
              else {
                console.log(key);
                folders.push(`INBOX.${key}`);
              }
            }

          });
        });

        connection.once("error", function (err) {
          console.log(err);
          throw err;
        });

        connection.once("end", function () {
          console.log("Connection ended ");
          resolve(folders);
        });

        connection.connect();
@martinericksonn martinericksonn changed the title Loop trough getboxes and get mail in each box Connection not closing after getBoxes execution. Jan 27, 2023
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

1 participant