Skip to content

Commit 85c6177

Browse files
authored
Merge pull request #85 from JJ-Cro/master
chore(v1.3.1): update version to 1.3.1 and improve error handling in WebsocketAPIClient
2 parents 99234cc + 9caba1c commit 85c6177

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

package-lock.json

Lines changed: 2 additions & 13 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": "gateio-api",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Complete & Robust Node.js SDK for Gate.com's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.",
55
"scripts": {
66
"clean": "rm -rf dist/*",

src/WebsocketAPIClient.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,17 @@ export class WebsocketAPIClient {
360360
console.info(new Date(), 'ws has authenticated ', data?.wsKey);
361361
})
362362
.on('exception', (data) => {
363-
console.error(new Date(), 'ws exception: ', JSON.stringify(data));
363+
try {
364+
// Blind JSON.stringify can fail on circular references
365+
console.error(
366+
new Date(),
367+
'ws exception: ',
368+
JSON.stringify(data),
369+
// JSON.stringify({ ...data, target: 'WebSocket' }),
370+
);
371+
} catch {
372+
console.error(new Date(), 'ws exception: ', data);
373+
}
364374
});
365375
}
366376
}

0 commit comments

Comments
 (0)