File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -82,3 +82,5 @@ export function getInitialSendRateLimitState(): SendRateLimitState {
8282 resetAt : Date . now ( ) + 60_000 ,
8383 } ;
8484}
85+
86+ export const KnownNetworkErrorCodes = new Set ( [ 'ECONNRESET' , 'ECONNREFUSED' , 'ETIMEDOUT' ] ) ;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import {
2626 CompressionMethod ,
2727 CompressionParameterMap ,
2828 ImportantGatewayOpcodes ,
29+ KnownNetworkErrorCodes ,
2930 getInitialSendRateLimitState ,
3031} from '../utils/constants.js' ;
3132import type { SessionInfo } from './WebSocketManager.js' ;
@@ -113,7 +114,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
113114 // Indicates whether the shard has already resolved its original connect() call
114115 private initialConnectResolved = false ;
115116
116- // Indicates if we failed to connect to the ws url (ECONNREFUSED/ECONNRESET)
117+ // Indicates if we failed to connect to the ws url
117118 private failedToConnectDueToNetworkError = false ;
118119
119120 private readonly sendQueue = new AsyncQueue ( ) ;
@@ -791,7 +792,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
791792 }
792793
793794 private onError ( error : Error ) {
794- if ( 'code' in error && [ 'ECONNRESET' , 'ECONNREFUSED' ] . includes ( error . code as string ) ) {
795+ if ( 'code' in error && KnownNetworkErrorCodes . has ( error . code as string ) ) {
795796 this . debug ( [ 'Failed to connect to the gateway URL specified due to a network error' ] ) ;
796797 this . failedToConnectDueToNetworkError = true ;
797798 return ;
You can’t perform that action at this time.
0 commit comments