Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebsocketClient.on("error") event throws type error "Argument of type '(data: any) => void' is not assignable to parameter of type 'never'" #413

Closed
tiagosiebler opened this issue Feb 6, 2025 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@tiagosiebler
Copy link
Owner

This might cause some friction for anyone updating but I wanted to make it as obvious & clear as possible, to avoid the risk of anyone missing useful error events after upgrading. Trying to consume "error" events from the WebsocketClient now gives a type error:

Image
const wsClient = new WebsocketClient();
wsClient.on('error', (data) => {
  console.error('ws exception: ', data);
});

This is expected, as of version v4.0.0 of the bybit-api Node.js/JavaScript/TypeScript SDK for Bybit's REST APIs and WebSockets. Emitting an error event was intended to communicate when issues happen, but had the unintended consequence of throwing unhandled exceptions, since the emitted errors are not Error instances.

As of v4.0.0, you should listen to the "exception" event instead to monitor any potential issues within your usage of the SDK's WebsocketClient:

const wsClient = new WebsocketClient();
wsClient.on('exception', (data) => {
  console.error('ws exception: ', data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant