From 08674ab2fa01ab46712525d022da9f30a201fdd5 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Sat, 17 Sep 2022 11:05:20 +0100 Subject: [PATCH] fix error log when reconnect cycle fails --- examples/ws-public.ts | 16 ++++++++++------ src/websocket-client.ts | 6 ++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/ws-public.ts b/examples/ws-public.ts index bfe8528..6f2ae90 100644 --- a/examples/ws-public.ts +++ b/examples/ws-public.ts @@ -13,12 +13,12 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src'; { // key: key, // secret: secret, + // market: 'linear', // market: 'inverse', - market: 'linear', // market: 'spot', // market: 'spotv3', // market: 'usdcOption', - // market: 'usdcPerp', + market: 'usdcPerp', // market: 'unifiedPerp', // market: 'unifiedOption', }, @@ -56,16 +56,20 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src'; // wsClient.subscribe('trade'); // Linear - wsClient.subscribe('trade.BTCUSDT'); + // wsClient.subscribe('trade.BTCUSDT'); // Spot V3 + // wsClient.subscribe('trade.BTCUSDT'); // usdc options - // wsClient.subscribe(`recenttrades.BTC`); - // wsClient.subscribe(`recenttrades.ETH`); - // wsClient.subscribe(`recenttrades.SOL`); + // wsClient.subscribe([ + // `recenttrades.BTC`, + // `recenttrades.ETH`, + // `recenttrades.SOL`, + // ]); // usdc perps + wsClient.subscribe('trade.BTCPERP'); // unified perps diff --git a/src/websocket-client.ts b/src/websocket-client.ts index 80cba8a..4a0e52c 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -358,8 +358,10 @@ export class WebsocketClient extends EventEmitter { default: this.logger.error( - `{context} due to unexpected response error: ${error.msg}`, - { ...loggerCategory, wsKey } + `${context} due to unexpected response error: "${ + error?.msg || error?.message || error + }"`, + { ...loggerCategory, wsKey, error } ); break; }