dolphindb 3.0.33 → 3.0.34
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.d.ts +1 -0
- package/browser.js +14 -1
- package/browser.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +14 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -610,6 +610,7 @@ export declare class DDB {
|
|
|
610
610
|
print_object_buffer: boolean;
|
|
611
611
|
print_message: boolean;
|
|
612
612
|
parse_object: boolean;
|
|
613
|
+
heartbeat_aborter?: AbortController;
|
|
613
614
|
/** 在 websocket 收到的第一个 error 时,
|
|
614
615
|
在 connect_websocket 的 on_error 回调中构造 DdbConnectionError 并保存到 DDB 对象上,
|
|
615
616
|
这个 error 的错误信息最准确 */
|
package/index.js
CHANGED
|
@@ -2511,6 +2511,7 @@ export class DDB {
|
|
|
2511
2511
|
print_object_buffer = false;
|
|
2512
2512
|
print_message = true;
|
|
2513
2513
|
parse_object = true;
|
|
2514
|
+
heartbeat_aborter;
|
|
2514
2515
|
/** 在 websocket 收到的第一个 error 时,
|
|
2515
2516
|
在 connect_websocket 的 on_error 回调中构造 DdbConnectionError 并保存到 DDB 对象上,
|
|
2516
2517
|
这个 error 的错误信息最准确 */
|
|
@@ -2614,7 +2615,11 @@ export class DDB {
|
|
|
2614
2615
|
},
|
|
2615
2616
|
on_error: error => {
|
|
2616
2617
|
this.error ??= new DdbConnectionError(this.url, error);
|
|
2618
|
+
this.heartbeat_aborter?.abort();
|
|
2617
2619
|
this.on_error();
|
|
2620
|
+
},
|
|
2621
|
+
on_close: () => {
|
|
2622
|
+
this.heartbeat_aborter?.abort();
|
|
2618
2623
|
}
|
|
2619
2624
|
});
|
|
2620
2625
|
}
|
|
@@ -2631,8 +2636,15 @@ export class DDB {
|
|
|
2631
2636
|
else
|
|
2632
2637
|
// 定时执行一次空脚本作为心跳检查,避免因为 nat 超时导致 tcp 连接断开
|
|
2633
2638
|
(async () => {
|
|
2639
|
+
this.heartbeat_aborter = new AbortController();
|
|
2634
2640
|
while (true) {
|
|
2635
|
-
|
|
2641
|
+
// 连接主动关闭时从循环退出防止影响 node.js 退出
|
|
2642
|
+
try {
|
|
2643
|
+
await delay(1000 * 60 * 4.5, { signal: this.heartbeat_aborter.signal });
|
|
2644
|
+
}
|
|
2645
|
+
catch {
|
|
2646
|
+
break;
|
|
2647
|
+
}
|
|
2636
2648
|
if (this.connected)
|
|
2637
2649
|
try {
|
|
2638
2650
|
await this.eval('');
|
|
@@ -2687,6 +2699,7 @@ export class DDB {
|
|
|
2687
2699
|
return options.join('_');
|
|
2688
2700
|
}
|
|
2689
2701
|
disconnect() {
|
|
2702
|
+
this.heartbeat_aborter?.abort();
|
|
2690
2703
|
const { resource } = this.lwebsocket;
|
|
2691
2704
|
if (resource) {
|
|
2692
2705
|
const { readyState } = resource;
|