Only react to events from the current socket when reconnecting
@devsingh05▲ 13 net votes
Closing an old WebSocket fires its close event after the replacement connection has already been started, which triggered a second spurious reconnect (and burned a rate-limited token each time). Tag each connection with an id/generation and have every handler return early if it is not the current one.