Skip to content

Commit 6f2edb9

Browse files
authored
Merge pull request #154 from JJ-Cro/master
chore(3.0.10): update version to 3.0.10 and improve error handling in WebsocketAPIClient
2 parents 5ddbb45 + 1f9880e commit 6f2edb9

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
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": "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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)