@larksuiteoapi/node-sdk 1.48.0 → 1.49.0-alpha.0

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/es/index.js CHANGED
@@ -82830,8 +82830,6 @@ class WSClient {
82830
82830
  return Promise.resolve(true);
82831
82831
  }
82832
82832
  return Promise.resolve(false);
82833
- }).finally(() => {
82834
- this.isConnecting = false;
82835
82833
  });
82836
82834
  };
82837
82835
  if (this.pingInterval) {
@@ -82842,7 +82840,16 @@ class WSClient {
82842
82840
  if (wsInstance) {
82843
82841
  wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
82844
82842
  }
82845
- const isSuccess = yield tryConnect();
82843
+ if (this.reconnectInterval) {
82844
+ clearTimeout(this.reconnectInterval);
82845
+ }
82846
+ let isSuccess = false;
82847
+ try {
82848
+ isSuccess = yield tryConnect();
82849
+ }
82850
+ finally {
82851
+ this.isConnecting = false;
82852
+ }
82846
82853
  if (!isSuccess) {
82847
82854
  this.logger.error('[ws]', 'connect failed');
82848
82855
  yield this.reConnect();
@@ -82859,7 +82866,7 @@ class WSClient {
82859
82866
  wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
82860
82867
  }
82861
82868
  this.wsConfig.setWSInstance(null);
82862
- setTimeout(() => __awaiter(this, void 0, void 0, function* () {
82869
+ this.reconnectInterval = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
82863
82870
  (function loopReConnect(count) {
82864
82871
  return __awaiter(this, void 0, void 0, function* () {
82865
82872
  count++;
@@ -82867,13 +82874,15 @@ class WSClient {
82867
82874
  // if reconnectCount < 0, the reconnect time is infinite
82868
82875
  if (isSuccess) {
82869
82876
  this.logger.debug('[ws]', 'reconnect success');
82877
+ this.isConnecting = false;
82870
82878
  return;
82871
82879
  }
82872
82880
  this.logger.info('ws', `unable to connect to the server after trying ${count} times")`);
82873
82881
  if (reconnectCount >= 0 && count >= reconnectCount) {
82882
+ this.isConnecting = false;
82874
82883
  return;
82875
82884
  }
82876
- setTimeout(() => {
82885
+ this.reconnectInterval = setTimeout(() => {
82877
82886
  loopReConnect.bind(this)(count);
82878
82887
  }, reconnectInterval);
82879
82888
  });
package/lib/index.js CHANGED
@@ -82845,8 +82845,6 @@ class WSClient {
82845
82845
  return Promise.resolve(true);
82846
82846
  }
82847
82847
  return Promise.resolve(false);
82848
- }).finally(() => {
82849
- this.isConnecting = false;
82850
82848
  });
82851
82849
  };
82852
82850
  if (this.pingInterval) {
@@ -82857,7 +82855,16 @@ class WSClient {
82857
82855
  if (wsInstance) {
82858
82856
  wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
82859
82857
  }
82860
- const isSuccess = yield tryConnect();
82858
+ if (this.reconnectInterval) {
82859
+ clearTimeout(this.reconnectInterval);
82860
+ }
82861
+ let isSuccess = false;
82862
+ try {
82863
+ isSuccess = yield tryConnect();
82864
+ }
82865
+ finally {
82866
+ this.isConnecting = false;
82867
+ }
82861
82868
  if (!isSuccess) {
82862
82869
  this.logger.error('[ws]', 'connect failed');
82863
82870
  yield this.reConnect();
@@ -82874,7 +82881,7 @@ class WSClient {
82874
82881
  wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
82875
82882
  }
82876
82883
  this.wsConfig.setWSInstance(null);
82877
- setTimeout(() => __awaiter(this, void 0, void 0, function* () {
82884
+ this.reconnectInterval = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
82878
82885
  (function loopReConnect(count) {
82879
82886
  return __awaiter(this, void 0, void 0, function* () {
82880
82887
  count++;
@@ -82882,13 +82889,15 @@ class WSClient {
82882
82889
  // if reconnectCount < 0, the reconnect time is infinite
82883
82890
  if (isSuccess) {
82884
82891
  this.logger.debug('[ws]', 'reconnect success');
82892
+ this.isConnecting = false;
82885
82893
  return;
82886
82894
  }
82887
82895
  this.logger.info('ws', `unable to connect to the server after trying ${count} times")`);
82888
82896
  if (reconnectCount >= 0 && count >= reconnectCount) {
82897
+ this.isConnecting = false;
82889
82898
  return;
82890
82899
  }
82891
- setTimeout(() => {
82900
+ this.reconnectInterval = setTimeout(() => {
82892
82901
  loopReConnect.bind(this)(count);
82893
82902
  }, reconnectInterval);
82894
82903
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larksuiteoapi/node-sdk",
3
- "version": "1.48.0",
3
+ "version": "1.49.0-alpha.0",
4
4
  "description": "larksuite open sdk for nodejs",
5
5
  "keywords": [
6
6
  "feishu",
package/types/index.d.ts CHANGED
@@ -265917,6 +265917,7 @@ declare class WSClient {
265917
265917
  private httpInstance;
265918
265918
  private eventDispatcher?;
265919
265919
  private pingInterval?;
265920
+ private reconnectInterval?;
265920
265921
  private isConnecting;
265921
265922
  constructor(params: IConstructorParams);
265922
265923
  private pullConnectConfig;