Just emit an "error" event instead of a separate "disconnect" event.
Compiled source