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/browser.js CHANGED
@@ -5,7 +5,7 @@ import ipaddrjs from 'ipaddr.js';
5
5
  const { fromByteArray: buf2ipaddr } = ipaddrjs;
6
6
  import 'xshell/prototype.browser.js';
7
7
  import { blue, cyan, green, grey, magenta } from 'xshell/chalk.browser.js';
8
- import { concat, assert, Lock, genid, seq, zip_object, decode } from 'xshell/utils.browser.js';
8
+ import { concat, assert, Lock, genid, seq, zip_object, decode, delay } from 'xshell/utils.browser.js';
9
9
  import { connect_websocket } from 'xshell/net.browser.js';
10
10
  import { t } from './i18n/index.js';
11
11
  export const nulls = {
@@ -2650,6 +2650,23 @@ export class DDB {
2650
2650
  await this.rpc('connect', { skip_connection_check: true });
2651
2651
  if (this.streaming)
2652
2652
  await this.subscribe();
2653
+ else
2654
+ // 定时执行一次空脚本作为心跳检查,避免因为 nat 超时导致 tcp 连接断开
2655
+ (async () => {
2656
+ while (true) {
2657
+ await delay(1000 * 60 * 4.5);
2658
+ if (this.connected)
2659
+ try {
2660
+ await this.eval('');
2661
+ }
2662
+ catch (error) {
2663
+ console.log(t('{{time}} 心跳检测失败,连接已断开', { time: new Date().to_formal_str() }), error);
2664
+ break;
2665
+ }
2666
+ else
2667
+ break;
2668
+ }
2669
+ })();
2653
2670
  resolve();
2654
2671
  }
2655
2672
  catch (error) {
@@ -3103,13 +3120,22 @@ export class DDB {
3103
3120
  first = false;
3104
3121
  }
3105
3122
  else {
3106
- const _data = obj.data();
3107
- const rows = _data[0].length;
3108
- const { columns } = schema;
3109
- data = {
3110
- ...schema,
3111
- data: seq(rows, i => zip_object(columns, seq(columns.length, j => _data[j][i])))
3112
- };
3123
+ let rows;
3124
+ // 用了流数据过滤功能后,必然发 table
3125
+ if (obj.form === DdbForm.table) {
3126
+ data = obj.data();
3127
+ data.name ||= schema.name;
3128
+ rows = data.data.length;
3129
+ }
3130
+ else {
3131
+ const _data = obj.data();
3132
+ const { columns } = schema;
3133
+ rows = _data[0]?.length || 0;
3134
+ data = {
3135
+ ...schema,
3136
+ data: seq(rows, i => zip_object(columns, seq(columns.length, j => _data[j][i])))
3137
+ };
3138
+ }
3113
3139
  win.rows += rows;
3114
3140
  win.segments.push(data);
3115
3141
  win.objs.push(obj);