dolphindb 3.0.29 → 3.0.31

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/i18n/dict.json CHANGED
@@ -85,5 +85,8 @@
85
85
  },
86
86
  " 暂时不支持转换为 js 对象": {
87
87
  "en": " conversion to js object is not supported at the moment"
88
+ },
89
+ "{{time}} 心跳检测失败,连接已断开": {
90
+ "en": "{{time}} heartbeat detection failed, the connection has been disconnected"
88
91
  }
89
92
  }
package/index.js CHANGED
@@ -3,7 +3,7 @@ import DayjsCustomParseFormat from 'dayjs/plugin/customParseFormat.js';
3
3
  dayjs.extend(DayjsCustomParseFormat);
4
4
  import ipaddrjs from 'ipaddr.js';
5
5
  const { fromByteArray: buf2ipaddr } = ipaddrjs;
6
- import { concat, assert, inspect, typed_array_to_buffer, connect_websocket, Lock, genid, seq, zip_object, WebSocketOpen, WebSocketClosed, WebSocketClosing, decode, } from 'xshell';
6
+ import { concat, assert, inspect, typed_array_to_buffer, connect_websocket, Lock, genid, seq, zip_object, WebSocketOpen, WebSocketClosed, WebSocketClosing, decode, delay } from 'xshell';
7
7
  import { t } from './i18n/index.js';
8
8
  export const nulls = {
9
9
  int8: -0x80, // -128
@@ -2628,6 +2628,23 @@ export class DDB {
2628
2628
  await this.rpc('connect', { skip_connection_check: true });
2629
2629
  if (this.streaming)
2630
2630
  await this.subscribe();
2631
+ else
2632
+ // 定时执行一次空脚本作为心跳检查,避免因为 nat 超时导致 tcp 连接断开
2633
+ (async () => {
2634
+ while (true) {
2635
+ await delay(1000 * 60 * 4.5);
2636
+ if (this.connected)
2637
+ try {
2638
+ await this.eval('');
2639
+ }
2640
+ catch (error) {
2641
+ console.log(t('{{time}} 心跳检测失败,连接已断开', { time: new Date().to_formal_str() }), error);
2642
+ break;
2643
+ }
2644
+ else
2645
+ break;
2646
+ }
2647
+ })();
2631
2648
  resolve();
2632
2649
  }
2633
2650
  catch (error) {
@@ -3081,13 +3098,22 @@ export class DDB {
3081
3098
  first = false;
3082
3099
  }
3083
3100
  else {
3084
- const _data = obj.data();
3085
- const rows = _data[0].length;
3086
- const { columns } = schema;
3087
- data = {
3088
- ...schema,
3089
- data: seq(rows, i => zip_object(columns, seq(columns.length, j => _data[j][i])))
3090
- };
3101
+ let rows;
3102
+ // 用了流数据过滤功能后,必然发 table
3103
+ if (obj.form === DdbForm.table) {
3104
+ data = obj.data();
3105
+ data.name ||= schema.name;
3106
+ rows = data.data.length;
3107
+ }
3108
+ else {
3109
+ const _data = obj.data();
3110
+ const { columns } = schema;
3111
+ rows = _data[0]?.length || 0;
3112
+ data = {
3113
+ ...schema,
3114
+ data: seq(rows, i => zip_object(columns, seq(columns.length, j => _data[j][i])))
3115
+ };
3116
+ }
3091
3117
  win.rows += rows;
3092
3118
  win.segments.push(data);
3093
3119
  win.objs.push(obj);