@@ -21,9 +21,15 @@ import {
21
21
type GatewaySendPayload ,
22
22
} from 'discord-api-types/v10' ;
23
23
import { WebSocket , type Data } from 'ws' ;
24
- import type { Inflate } from 'zlib-sync' ;
25
- import type { IContextFetchingStrategy } from '../strategies/context/IContextFetchingStrategy.js' ;
26
- import { ImportantGatewayOpcodes , getInitialSendRateLimitState } from '../utils/constants.js' ;
24
+ import type * as ZlibSync from 'zlib-sync' ;
25
+ import type { IContextFetchingStrategy } from '../strategies/context/IContextFetchingStrategy' ;
26
+ import {
27
+ CompressionMethod ,
28
+ CompressionParameterMap ,
29
+ ImportantGatewayOpcodes ,
30
+ KnownNetworkErrorCodes ,
31
+ getInitialSendRateLimitState ,
32
+ } from '../utils/constants.js' ;
27
33
import type { SessionInfo } from './WebSocketManager.js' ;
28
34
29
35
// eslint-disable-next-line promise/prefer-await-to-then
@@ -107,7 +113,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
107
113
// Indicates whether the shard has already resolved its original connect() call
108
114
private initialConnectResolved = false ;
109
115
110
- // Indicates if we failed to connect to the ws url (ECONNREFUSED/ECONNRESET)
116
+ // Indicates if we failed to connect to the ws url
111
117
private failedToConnectDueToNetworkError = false ;
112
118
113
119
private readonly sendQueue = new AsyncQueue ( ) ;
@@ -710,7 +716,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
710
716
}
711
717
712
718
private onError ( error : Error ) {
713
- if ( 'code' in error && [ 'ECONNRESET' , 'ECONNREFUSED' ] . includes ( error . code as string ) ) {
719
+ if ( 'code' in error && KnownNetworkErrorCodes . has ( error . code as string ) ) {
714
720
this . debug ( [ 'Failed to connect to the gateway URL specified due to a network error' ] ) ;
715
721
this . failedToConnectDueToNetworkError = true ;
716
722
return ;
0 commit comments