Skip to content

Commit

Permalink
fix(4.0.0-beta.1): fix backwards compatibility with req_id usage for …
Browse files Browse the repository at this point in the history
…ws subscribe/unsubscribe
  • Loading branch information
tiagosiebler committed Jan 24, 2025
1 parent 86fc739 commit 8a69214
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bybit-api",
"version": "4.0.0-beta.0",
"version": "4.0.0-beta.1",
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
1 change: 0 additions & 1 deletion src/util/BaseRestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import https from 'https';

import {
APIID,
REST_CLIENT_TYPE_ENUM,
RestClientOptions,
RestClientType,
getRestBaseUrl,
Expand Down
12 changes: 10 additions & 2 deletions src/websocket-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,18 @@ export class WebsocketClient extends BaseWebsocketClient<

switch (market) {
case 'all': {
const topics = requests.map((r) => r.topic);

// Previously used to track topics in a request. Keeping this for subscribe/unsubscribe requests, no need for incremental values
const req_id =
['subscribe', 'unsubscribe'].includes(operation) && topics.length
? topics.join('_')
: this.getNewRequestId();

const wsEvent: WsRequestOperationBybit<WsTopic> = {
req_id: this.getNewRequestId(),
req_id: req_id,
op: operation,
args: requests.map((r) => r.topic),
args: topics,
};

const midflightWsEvent: MidflightWsRequestEvent<
Expand Down

0 comments on commit 8a69214

Please sign in to comment.