@binance/common 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -943,12 +943,16 @@ var WebsocketCommon = class _WebsocketCommon extends WebsocketEventEmitter {
943
943
  */
944
944
  async closeConnectionGracefully(WebsocketConnectionToClose, connection) {
945
945
  if (!WebsocketConnectionToClose || !connection) return;
946
- this.logger.debug("Waiting for pending requests to complete before disconnecting.");
946
+ this.logger.debug(
947
+ `Waiting for pending requests to complete before disconnecting websocket on connection ${connection.id}.`
948
+ );
947
949
  const closePromise = new Promise((resolve) => {
948
950
  this.scheduleTimer(
949
951
  WebsocketConnectionToClose,
950
952
  () => {
951
- this.logger.warn("Force-closing connection after 30 seconds.");
953
+ this.logger.warn(
954
+ `Force-closing websocket connection after 30 seconds on connection ${connection.id}.`
955
+ );
952
956
  resolve();
953
957
  },
954
958
  3e4
@@ -957,7 +961,9 @@ var WebsocketCommon = class _WebsocketCommon extends WebsocketEventEmitter {
957
961
  WebsocketConnectionToClose,
958
962
  () => {
959
963
  if (connection.pendingRequests.size === 0) {
960
- this.logger.debug("All pending requests completed, closing connection.");
964
+ this.logger.debug(
965
+ `All pending requests completed, closing websocket connection on connection ${connection.id}.`
966
+ );
961
967
  resolve();
962
968
  }
963
969
  },
@@ -966,7 +972,7 @@ var WebsocketCommon = class _WebsocketCommon extends WebsocketEventEmitter {
966
972
  );
967
973
  });
968
974
  await closePromise;
969
- this.logger.info("Closing Websocket connection.");
975
+ this.logger.info(`Closing Websocket connection on connection ${connection.id}.`);
970
976
  WebsocketConnectionToClose.close();
971
977
  this.cleanup(WebsocketConnectionToClose);
972
978
  }
@@ -986,7 +992,7 @@ var WebsocketCommon = class _WebsocketCommon extends WebsocketEventEmitter {
986
992
  req.payload,
987
993
  req.options
988
994
  );
989
- this.logger.debug(`Session re-logon with connection id: ${connection.id}`, data);
995
+ this.logger.debug(`Session re-logon on connection ${connection.id}`, data);
990
996
  try {
991
997
  await this.send(
992
998
  JSON.stringify(data),
@@ -995,12 +1001,12 @@ var WebsocketCommon = class _WebsocketCommon extends WebsocketEventEmitter {
995
1001
  this.configuration.timeout,
996
1002
  connection
997
1003
  );
1004
+ this.logger.debug(
1005
+ `Session re-logon on connection ${connection.id} was successful.`
1006
+ );
998
1007
  connection.isSessionLoggedOn = true;
999
1008
  } catch (err) {
1000
- this.logger.error(
1001
- `Session re-logon with connection id ${connection.id} failed:`,
1002
- err
1003
- );
1009
+ this.logger.error(`Session re-logon on connection ${connection.id} failed:`, err);
1004
1010
  }
1005
1011
  }
1006
1012
  }
@@ -1364,8 +1370,9 @@ var WebsocketAPIBase = class extends WebsocketCommon {
1364
1370
  if (!this.isConnected()) {
1365
1371
  throw new Error("Not connected");
1366
1372
  }
1367
- const connections = options.isSessionLogon || options.isSessionLogout ? this.getAvailableConnections() : [this.getConnection()];
1368
- const skipAuth = options.isSessionLogon || options.isSessionLogout ? false : this.configuration.autoSessionReLogon && connections[0].isSessionLoggedOn;
1373
+ const isSessionReq = options.isSessionLogon || options.isSessionLogout;
1374
+ const connections = isSessionReq ? this.getAvailableConnections() : [this.getConnection()];
1375
+ const skipAuth = isSessionReq ? false : this.configuration.autoSessionReLogon && connections[0].isSessionLoggedOn;
1369
1376
  const data = buildWebsocketAPIMessage(
1370
1377
  this.configuration,
1371
1378
  method,
@@ -1385,7 +1392,7 @@ var WebsocketAPIBase = class extends WebsocketCommon {
1385
1392
  )
1386
1393
  )
1387
1394
  );
1388
- if ((options.isSessionLogon || options.isSessionLogout) && this.configuration.autoSessionReLogon) {
1395
+ if (isSessionReq && this.configuration.autoSessionReLogon) {
1389
1396
  connections.forEach((connection) => {
1390
1397
  if (options.isSessionLogon) {
1391
1398
  connection.isSessionLoggedOn = true;
@@ -1396,7 +1403,7 @@ var WebsocketAPIBase = class extends WebsocketCommon {
1396
1403
  }
1397
1404
  });
1398
1405
  }
1399
- return connections.length === 1 ? responses[0] : responses;
1406
+ return connections.length === 1 && !isSessionReq ? responses[0] : responses;
1400
1407
  }
1401
1408
  };
1402
1409
  var WebsocketStreamsBase = class extends WebsocketCommon {
@@ -1559,7 +1566,7 @@ var WebsocketStreamsBase = class extends WebsocketCommon {
1559
1566
  connectionStreamMap.forEach((streams2, connection) => {
1560
1567
  if (!this.isConnected(connection)) {
1561
1568
  this.logger.info(
1562
- `Connection is not ready. Queuing subscription for streams: ${streams2}`
1569
+ `Connection ${connection.id} is not ready. Queuing subscription for streams: ${streams2}`
1563
1570
  );
1564
1571
  connection.pendingSubscriptions?.push(...streams2);
1565
1572
  return;