dolphindb 2.0.956 → 2.0.957

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/browser.js CHANGED
@@ -2367,9 +2367,13 @@ class DDB {
2367
2367
  return options.join('_');
2368
2368
  }
2369
2369
  disconnect() {
2370
- if (this.connected)
2371
- // 这里不获取 lock,直接关闭连接
2372
- this.lwebsocket.resource.close(1000);
2370
+ const { resource } = this.lwebsocket;
2371
+ if (resource) {
2372
+ const { readyState } = resource;
2373
+ if (readyState !== WebSocket.CLOSED && readyState !== WebSocket.CLOSING)
2374
+ // 这里不获取 lock,直接关闭连接
2375
+ resource.close(1000);
2376
+ }
2373
2377
  }
2374
2378
  /** (内部使用的方法) rpc through websocket (function/script/variable command)
2375
2379
  未连接到 DDB 时调用会自动连接,连接断开时调用会抛出 DdbConnectionError