does on('close') get called after on('error') ? because if it does not, this will cause the process to hang forever because callback is not called.