fix(WebSocketShard): don't close in #destroy when status is connecting (#9254)

This commit is contained in:
DD
2023-03-20 21:20:48 +02:00
committed by GitHub
parent 229ad077ff
commit c76b17d3b3

View File

@@ -224,8 +224,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
// Prevent a reconnection loop by unbinding the main close event
this.connection.removeAllListeners('close');
const shouldClose =
this.connection.readyState === WebSocket.OPEN || this.connection.readyState === WebSocket.CONNECTING;
const shouldClose = this.connection.readyState === WebSocket.OPEN;
this.debug([
'Connection status during destroy',
@@ -301,7 +300,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
// If the error is handled, we can just try to reconnect
await this.destroy({
code: CloseCodes.Normal,
reason: 'Something timed out',
reason: 'Something timed out or went wrong while waiting for an event',
recover: WebSocketShardDestroyRecovery.Reconnect,
});