fix(4.0.0-beta.1): fix backwards compatibility with req_id usage for ws subscribe/unsubscribe

This commit is contained in:
tiagosiebler
2025-01-24 16:20:12 +00:00
parent 86fc739eca
commit 8a692140e0
4 changed files with 13 additions and 6 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "bybit-api", "name": "bybit-api",
"version": "4.0.0-beta.0", "version": "4.0.0-beta.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "bybit-api", "name": "bybit-api",
"version": "4.0.0-beta.0", "version": "4.0.0-beta.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^1.7.9", "axios": "^1.7.9",

View File

@@ -1,6 +1,6 @@
{ {
"name": "bybit-api", "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.", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@@ -4,7 +4,6 @@ import https from 'https';
import { import {
APIID, APIID,
REST_CLIENT_TYPE_ENUM,
RestClientOptions, RestClientOptions,
RestClientType, RestClientType,
getRestBaseUrl, getRestBaseUrl,

View File

@@ -550,10 +550,18 @@ export class WebsocketClient extends BaseWebsocketClient<
switch (market) { switch (market) {
case 'all': { 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> = { const wsEvent: WsRequestOperationBybit<WsTopic> = {
req_id: this.getNewRequestId(), req_id: req_id,
op: operation, op: operation,
args: requests.map((r) => r.topic), args: topics,
}; };
const midflightWsEvent: MidflightWsRequestEvent< const midflightWsEvent: MidflightWsRequestEvent<