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 {
82
82
resetAt : Date . now ( ) + 60_000 ,
83
83
} ;
84
84
}
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 {
26
26
CompressionMethod ,
27
27
CompressionParameterMap ,
28
28
ImportantGatewayOpcodes ,
29
+ KnownNetworkErrorCodes ,
29
30
getInitialSendRateLimitState ,
30
31
} from '../utils/constants.js' ;
31
32
import type { SessionInfo } from './WebSocketManager.js' ;
@@ -113,7 +114,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
113
114
// Indicates whether the shard has already resolved its original connect() call
114
115
private initialConnectResolved = false ;
115
116
116
- // Indicates if we failed to connect to the ws url (ECONNREFUSED/ECONNRESET)
117
+ // Indicates if we failed to connect to the ws url
117
118
private failedToConnectDueToNetworkError = false ;
118
119
119
120
private readonly sendQueue = new AsyncQueue ( ) ;
@@ -791,7 +792,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
791
792
}
792
793
793
794
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 ) ) {
795
796
this . debug ( [ 'Failed to connect to the gateway URL specified due to a network error' ] ) ;
796
797
this . failedToConnectDueToNetworkError = true ;
797
798
return ;
You can’t perform that action at this time.
0 commit comments