Closed gitowiec closed 4 years ago
I have rewritten wipeoutInbox
partially because I was not sure if Promise.all
makes client.deleteMessages
calls sequentially and if it does not, the way it was makes problems for the imap server. But the error still persists:
export const wipeoutInbox = async (disableLogging?: boolean): Promise<boolean> => {
try {
getClient(disableLogging);
await connectClient(disableLogging);
let uids: string[] = await client.search('INBOX', {}, { byUid: true });
!disableLogging && console.log({ uids });
if (uids.length === 0) {
// await closeConnection(disableLogging)();
await client.close();
return true;
}
do {
await uids.reduce(async (previousPromise, nextUid) => {
await previousPromise;
return client.deleteMessages('INBOX', nextUid, { byUid: true });
}, Promise.resolve());
uids = await client.search('INBOX', {}, { byUid: true });
!disableLogging && console.log({ uidsAfter: uids });
} while (0 < uids.length);
// await closeConnection(disableLogging)();
await client.close();
return uids.length === 0;
} catch (e) {
// await closeConnection(disableLogging)();
try {
await client.close().catch((e) => console.log(e));
} catch (error) {
}
}
return false;
};
I managed to suppress the IDLE Error by adding client.client.onidle = null;
right after client = new ImapClient(...)
but I can't overcome long waiting time. I tried adding
client.timeoutIdle = 1000;
client.timeoutNoop = 1000;
But it does not help.
And yes, there is repeated client
because Client
class has its own property of the same name (thanks its public!)
I am closing this issue, it happen to be wrong configuration of WebdriverIO. I accidentaly declared two hooks (after and afterSuite) with call to wipeoutInbox()
. That means my code was trying to delete all messages in Inbox twice.
Hi First of all, thank you for great library. It helps us very much running our E2E tests. We are using
emailjs-imap-client
with Ethereal Email, it is such a convenient service. Recently I got this issue:When running this code
I use this
wipeoutInbox
to clean up the Inbox after tests suite. I don't know where to start, it is strange that exception is unhandled (as Node says in the last line of error) because as you can see it is all in try-catch block. We use this function when running E2E tests with WebDriverIO, Mocha and Chai. If there is any more info I should share, just let me know. How to fix this error or catch it properly? Best regards