Flipped if-else and added .splice(0) to oldListeners. I'm worried that no listeners is the reason socket.io used splice. Splice likely returns an empty array if there were no listeners.