postalsys / imapflow

IMAP Client library for EmailEngine Email API (https://emailengine.app)
https://imapflow.com
Other
350 stars 59 forks source link

destroySoon doesn't actually destroy the socket #200

Closed dumbasPL closed 2 months ago

dumbasPL commented 3 months ago

NodeJS's destroySoon will only destroy the socket once it's finished. Otherwise, it calls .end() and waits for the finish event which never happens in our case. This is problematic because after calling .logout() or .close() further calls to other APIs like .idle() don't error out and just silently fail (problematic if called in a loop for example). The current check for if (this.socket.destroyed) inside .run() will never trigger because the socket is never destroyed, just ended. Consider moving to destroy() or calling finish to actually destroy the socket.

temporary fix/hack:

this.client.logout().then(() => (this.client as unknown as {socket: Socket}).socket.destroy())
github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

dumbasPL commented 2 months ago

not stale

andris9 commented 2 months ago

Fixed in v1.0.163