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/browser.d.ts
CHANGED
|
@@ -618,6 +618,7 @@ export declare class DDB {
|
|
|
618
618
|
print_object_buffer: boolean;
|
|
619
619
|
print_message: boolean;
|
|
620
620
|
parse_object: boolean;
|
|
621
|
+
heartbeat_aborter?: AbortController;
|
|
621
622
|
/** 在 websocket 收到的第一个 error 时,
|
|
622
623
|
在 connect_websocket 的 on_error 回调中构造 DdbConnectionError 并保存到 DDB 对象上,
|
|
623
624
|
这个 error 的错误信息最准确 */
|
package/browser.js
CHANGED
|
@@ -2535,6 +2535,7 @@ export class DDB {
|
|
|
2535
2535
|
print_object_buffer = false;
|
|
2536
2536
|
print_message = true;
|
|
2537
2537
|
parse_object = true;
|
|
2538
|
+
heartbeat_aborter;
|
|
2538
2539
|
/** 在 websocket 收到的第一个 error 时,
|
|
2539
2540
|
在 connect_websocket 的 on_error 回调中构造 DdbConnectionError 并保存到 DDB 对象上,
|
|
2540
2541
|
这个 error 的错误信息最准确 */
|
|
@@ -2636,7 +2637,11 @@ export class DDB {
|
|
|
2636
2637
|
},
|
|
2637
2638
|
on_error: error => {
|
|
2638
2639
|
this.error ??= new DdbConnectionError(this.url, error);
|
|
2640
|
+
this.heartbeat_aborter?.abort();
|
|
2639
2641
|
this.on_error();
|
|
2642
|
+
},
|
|
2643
|
+
on_close: () => {
|
|
2644
|
+
this.heartbeat_aborter?.abort();
|
|
2640
2645
|
}
|
|
2641
2646
|
});
|
|
2642
2647
|
}
|
|
@@ -2653,8 +2658,15 @@ export class DDB {
|
|
|
2653
2658
|
else
|
|
2654
2659
|
// 定时执行一次空脚本作为心跳检查,避免因为 nat 超时导致 tcp 连接断开
|
|
2655
2660
|
(async () => {
|
|
2661
|
+
this.heartbeat_aborter = new AbortController();
|
|
2656
2662
|
while (true) {
|
|
2657
|
-
|
|
2663
|
+
// 连接主动关闭时从循环退出防止影响 node.js 退出
|
|
2664
|
+
try {
|
|
2665
|
+
await delay(1000 * 60 * 4.5, { signal: this.heartbeat_aborter.signal });
|
|
2666
|
+
}
|
|
2667
|
+
catch {
|
|
2668
|
+
break;
|
|
2669
|
+
}
|
|
2658
2670
|
if (this.connected)
|
|
2659
2671
|
try {
|
|
2660
2672
|
await this.eval('');
|
|
@@ -2709,6 +2721,7 @@ export class DDB {
|
|
|
2709
2721
|
return options.join('_');
|
|
2710
2722
|
}
|
|
2711
2723
|
disconnect() {
|
|
2724
|
+
this.heartbeat_aborter?.abort();
|
|
2712
2725
|
const { resource } = this.lwebsocket;
|
|
2713
2726
|
if (resource) {
|
|
2714
2727
|
const { readyState } = resource;
|