Skip to content

Commit 9bf8001

Browse files
committed
chore(3.0.10): update version to 3.0.10 and improve error handling in WebsocketAPIClient
1 parent 5ddbb45 commit 9bf8001

3 files changed

Lines changed: 26 additions & 16 deletions

File tree

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": "okx-api",
3-
"version": "3.0.9",
3+
"version": "3.0.10",
44
"description": "Complete Node.js SDK for OKX's REST APIs and WebSockets, with TypeScript & end-to-end tests",
55
"scripts": {
66
"test": "jest",

src/websocket-api-client.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { OrderIdRequest } from './types/rest/request/trade.js';
22
import { OrderResult } from './types/rest/response/private-trade.js';
3-
import { WSAPIResponse } from './types/websockets/ws-api.js';
43
import {
5-
WSAPIAmendOrderRequestV5,
6-
WSAPIAmendSpreadOrderRequestV5,
7-
WSAPICancelSpreadOrderRequestV5,
8-
WSAPIMassCancelOrdersRequestV5,
9-
WSAPIPlaceOrderRequestV5,
10-
WSAPIPlaceSpreadOrderRequestV5,
11-
WSAPISpreadMassCancelOrdersRequestV5,
4+
WSAPIAmendOrderRequestV5,
5+
WSAPIAmendSpreadOrderRequestV5,
6+
WSAPICancelSpreadOrderRequestV5,
7+
WSAPIMassCancelOrdersRequestV5,
8+
WSAPIPlaceOrderRequestV5,
9+
WSAPIPlaceSpreadOrderRequestV5,
10+
WSAPISpreadMassCancelOrdersRequestV5,
1211
} from './types/websockets/ws-api-request.js';
1312
import {
14-
WSAPICancelOrderResultV5,
15-
WSAPISpreadAmendOrderResultV5,
16-
WSAPISpreadCancelOrderResultV5,
17-
WSAPISpreadPlaceOrderResultV5,
13+
WSAPICancelOrderResultV5,
14+
WSAPISpreadAmendOrderResultV5,
15+
WSAPISpreadCancelOrderResultV5,
16+
WSAPISpreadPlaceOrderResultV5,
1817
} from './types/websockets/ws-api-response.js';
18+
import { WSAPIResponse } from './types/websockets/ws-api.js';
1919
import { WSClientConfigurableOptions } from './types/websockets/ws-general.js';
2020
import { DefaultLogger } from './util/logger.js';
2121
import { WebsocketClient } from './websocket-client.js';
@@ -291,7 +291,17 @@ export class WebsocketAPIClient {
291291
console.info(new Date(), 'ws has authenticated ', data?.wsKey);
292292
})
293293
.on('exception', (data) => {
294-
console.error(new Date(), 'ws exception: ', JSON.stringify(data));
294+
try {
295+
// Blind JSON.stringify can fail on circular references
296+
console.error(
297+
new Date(),
298+
'ws exception: ',
299+
JSON.stringify(data),
300+
// JSON.stringify({ ...data, target: 'WebSocket' }),
301+
);
302+
} catch {
303+
console.error(new Date(), 'ws exception: ', data);
304+
}
295305
});
296306
}
297307
}

0 commit comments

Comments
 (0)