dolphindb 3.1.24 → 3.1.25

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/index.d.ts CHANGED
@@ -174,7 +174,7 @@ export interface InspectOptions extends UtilInspectOptions {
174
174
  export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
175
175
  /** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
176
176
  export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
177
- export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | number[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbSymbolExtendedValue | string[] | DdbExtObjValue | DdbTensorValue | Uint8Array<ArrayBufferLike> | IotVectorItemValue | DdbDurationVectorValue | DdbDecimal128VectorValue | BigInt128Array | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | DdbArrayVectorValue | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | DdbMatrixValue | DdbChartValue;
177
+ export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | number[] | string[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbSymbolExtendedValue | DdbExtObjValue | DdbTensorValue | Uint8Array<ArrayBufferLike> | IotVectorItemValue | DdbDurationVectorValue | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | DdbArrayVectorValue | DdbDecimal128VectorValue | DdbMatrixValue | DdbChartValue;
178
178
  /** 转换一个向量到 js 原生数组 */
179
179
  export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
180
180
  /** 构造 void 类型,默认为 `DdbVoidType.undefined` */
@@ -417,7 +417,6 @@ export declare class DDB {
417
417
  print_object_buffer: boolean;
418
418
  print_message: boolean;
419
419
  parse_object: boolean;
420
- heartbeat_aborter?: AbortController;
421
420
  /** 在 websocket 收到的第一个 error 时,
422
421
  在 connect_websocket 的 on_error 回调中构造 DdbConnectionError 并保存到 DDB 对象上,
423
422
  这个 error 的错误信息最准确 */
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { concat, assert, inspect, typed_array_to_buffer, connect_websocket, Lock, genid, seq, zip_object, WebSocketOpen, WebSocketClosed, WebSocketClosing, decode, delay, check, empty, colored } from 'xshell';
1
+ import { concat, assert, inspect, typed_array_to_buffer, connect_websocket, Lock, genid, seq, zip_object, WebSocketOpen, WebSocketClosed, WebSocketClosing, decode, check, empty, colored } from 'xshell';
2
2
  import { t } from "./i18n/index.js";
3
3
  import { ddb_tensor_bytes, DdbChartType, DdbDurationUnit, DdbForm, generate_array_type, DdbFunctionType, DdbType, DdbVoidType, dictables, function_definition_patterns, get_big_int_128, get_time_ddbobj, get_duration_unit, get_type_name, int1282str, ipaddr2str, is_decimal_null_value, is_decimal_type, time_formatters, number_nulls, nulls, set_big_int_128, uuid2str, get_times_ddbobj, funcdefs, get_number_formatter } from "./common.js";
4
4
  export * from "./common.js";
@@ -2410,7 +2410,6 @@ export class DDB {
2410
2410
  print_object_buffer = false;
2411
2411
  print_message = true;
2412
2412
  parse_object = true;
2413
- heartbeat_aborter;
2414
2413
  /** 在 websocket 收到的第一个 error 时,
2415
2414
  在 connect_websocket 的 on_error 回调中构造 DdbConnectionError 并保存到 DDB 对象上,
2416
2415
  这个 error 的错误信息最准确 */
@@ -2522,16 +2521,13 @@ export class DDB {
2522
2521
  this.lwebsocket.resource = await connect_websocket(url, {
2523
2522
  protocols: this.streaming ? ['streaming'] : this.dolphindb ? undefined : [this.language],
2524
2523
  proxy: this.proxy,
2524
+ keep_alive_duration: 30_000,
2525
2525
  on_message: (buffer, websocket) => {
2526
2526
  this.on_message(new Uint8Array(buffer), websocket);
2527
2527
  },
2528
2528
  on_error: error => {
2529
2529
  this.error ??= new DdbConnectionError(this.url, error);
2530
- this.heartbeat_aborter?.abort();
2531
2530
  this.on_error();
2532
- },
2533
- on_close: () => {
2534
- this.heartbeat_aborter?.abort();
2535
2531
  }
2536
2532
  });
2537
2533
  }
@@ -2545,30 +2541,6 @@ export class DDB {
2545
2541
  await this.rpc('connect', { skip_connection_check: true });
2546
2542
  if (this.streaming)
2547
2543
  await this.subscribe();
2548
- else
2549
- // 定时执行一次空脚本作为心跳检查,避免因为 nat 超时导致 tcp 连接断开
2550
- (async () => {
2551
- this.heartbeat_aborter = new AbortController();
2552
- while (true) {
2553
- // 连接主动关闭时从循环退出防止影响 node.js 退出
2554
- try {
2555
- await delay(1000 * 60 * 4.5, { signal: this.heartbeat_aborter.signal });
2556
- }
2557
- catch {
2558
- break;
2559
- }
2560
- if (this.connected)
2561
- try {
2562
- await this.eval('');
2563
- }
2564
- catch (error) {
2565
- console.log(t('{{time}} 心跳检测失败,连接已断开', { time: new Date().to_formal_str() }), error);
2566
- break;
2567
- }
2568
- else
2569
- break;
2570
- }
2571
- })();
2572
2544
  resolve();
2573
2545
  }
2574
2546
  catch (error) {
@@ -2614,7 +2586,6 @@ export class DDB {
2614
2586
  return options.join('_');
2615
2587
  }
2616
2588
  disconnect() {
2617
- this.heartbeat_aborter?.abort();
2618
2589
  const { resource } = this.lwebsocket;
2619
2590
  if (resource) {
2620
2591
  const { readyState } = resource;