Skip to content

Commit c72aed8

Browse files
committed
chore(3.0.9): bump version to 3.0.9 and improve error handling in WebsocketAPIClient
1 parent 0feb7b6 commit c72aed8

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bitget-api",
3-
"version": "3.0.8",
3+
"version": "3.0.9",
44
"description": "Complete Node.js & JavaScript SDK for Bitget V1-V3 REST APIs & WebSockets, with TypeScript & end-to-end tests.",
55
"scripts": {
66
"test": "jest",

src/websocket-api-client.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { CancelOrderRequestV3 } from './types/request/v3/trade.js';
22
import { CancelOrderResponseV3 } from './types/response/v3/trade.js';
3-
import { WSAPIResponse } from './types/websockets/ws-api.js';
43
import { WSAPIPlaceOrderRequestV3 } from './types/websockets/ws-api-request.js';
54
import { WSAPIPlaceOrderResponseV3 } from './types/websockets/ws-api-response.js';
5+
import { WSAPIResponse } from './types/websockets/ws-api.js';
66
import {
77
BitgetInstTypeV3,
88
WSClientConfigurableOptions,
@@ -187,7 +187,17 @@ export class WebsocketAPIClient {
187187
console.info(new Date(), 'ws has authenticated ', data?.wsKey);
188188
})
189189
.on('exception', (data) => {
190-
console.error(new Date(), 'ws exception: ', JSON.stringify(data));
190+
try {
191+
// Blind JSON.stringify can fail on circular references
192+
console.error(
193+
new Date(),
194+
'ws exception: ',
195+
JSON.stringify(data),
196+
// JSON.stringify({ ...data, target: 'WebSocket' }),
197+
);
198+
} catch {
199+
console.error(new Date(), 'ws exception: ', data);
200+
}
191201
});
192202
}
193203
}

0 commit comments

Comments
 (0)