Skip to content

Commit

Permalink
feat(): bump ws to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Apr 2, 2024
1 parent 616525e commit bb6f3fa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"dependencies": {
"axios": "^1.6.6",
"isomorphic-ws": "^4.0.1",
"ws": "^7.4.0"
"ws": "^8.16.0"
},
"devDependencies": {
"@types/axios": "^0.14.0",
Expand Down
14 changes: 11 additions & 3 deletions src/lib/BaseWSClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,15 @@ export abstract class BaseWebsocketClient<
this.clearPongTimer(wsKey);

this.logger.trace('Sending ping', { ...WS_LOGGER_CATEGORY, wsKey });
this.sendPingEvent(wsKey, this.wsStore.get(wsKey, true).ws);
const ws = this.wsStore.get(wsKey, true).ws;

if (!ws) {
this.logger.error(
`Unable to send ping for wsKey "${wsKey}" - no connection found`,
);
return;
}
this.sendPingEvent(wsKey, ws);

this.wsStore.get(wsKey, true).activePongTimer = setTimeout(() => {
this.logger.info('Pong timeout - closing socket to reconnect', {
Expand Down Expand Up @@ -570,8 +578,8 @@ export abstract class BaseWebsocketClient<
wsKey,
});

const agent = this.options.requestOptions?.agent;
const ws = new WebSocket(url, undefined, agent ? { agent } : undefined);
const ws = new WebSocket(url, undefined);

ws.onopen = (event: any) => this.onWsOpen(event, wsKey);
ws.onmessage = (event: any) => this.onWsMessage(event, wsKey);
ws.onerror = (event: any) =>
Expand Down
5 changes: 1 addition & 4 deletions src/types/websockets/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export interface WSClientConfigurableOptions {
/** Delay in milliseconds before respawning the connection */
reconnectTimeout?: number;

requestOptions?: {
/** override the user agent when opening the websocket connection (some proxies use this) */
agent?: string;
};
requestOptions?: {};

wsUrl?: string;

Expand Down

0 comments on commit bb6f3fa

Please sign in to comment.