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())
NodeJS's
destroySoon
will only destroy the socket once it's finished. Otherwise, it calls.end()
and waits for thefinish
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 forif (this.socket.destroyed)
inside.run()
will never trigger because the socket is never destroyed, just ended. Consider moving todestroy()
or callingfinish
to actually destroy the socket.temporary fix/hack: