dolphindb 2.0.1019 → 2.0.1021

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 CHANGED
@@ -376,15 +376,16 @@ export interface DdbRpcOptions {
376
376
  export declare class DdbConnectionError extends Error {
377
377
  name: string;
378
378
  cause?: WebSocketConnectionError;
379
- ddb: DDB;
380
- constructor(ddb: DDB, error?: WebSocketConnectionError);
379
+ url: string;
380
+ constructor(url: string, error?: WebSocketConnectionError);
381
381
  }
382
382
  export declare class DdbDatabaseError extends Error {
383
383
  name: string;
384
- ddb: DDB;
384
+ url: string;
385
+ id: number;
385
386
  type: DdbRpcType;
386
387
  options: DdbRpcOptions;
387
- constructor(message: string, ddb: DDB, type: DdbRpcType, options: DdbRpcOptions);
388
+ constructor(message: string, url: string, type: DdbRpcType, options: DdbRpcOptions, id: number);
388
389
  }
389
390
  /** SQL Standrd 标准类型 */
390
391
  export declare enum SqlStandard {
package/browser.js CHANGED
@@ -2097,24 +2097,28 @@ export const winsize = 10_0000;
2097
2097
  export class DdbConnectionError extends Error {
2098
2098
  name = 'DdbConnectionError';
2099
2099
  cause;
2100
- ddb;
2101
- constructor(ddb, error) {
2102
- super(error?.message || `${ddb.url} ${t('连接出错了,可能由于网络原因连接已被关闭,或服务器断开连接')}`, { cause: error });
2100
+ url;
2101
+ // 这里不保留 ddb 的引用,会导致无法序列化
2102
+ constructor(url, error) {
2103
+ super(error?.message || `${url} ${t('连接出错了,可能由于网络原因连接已被关闭,或服务器断开连接')}`, { cause: error });
2104
+ this.url = url;
2103
2105
  if (error)
2104
2106
  this.cause = error;
2105
- this.ddb = ddb;
2106
2107
  }
2107
2108
  }
2108
2109
  export class DdbDatabaseError extends Error {
2109
2110
  name = 'DdbDatabaseError';
2110
- ddb;
2111
+ url;
2112
+ // 这里不保留 ddb 的引用,会导致无法序列化
2113
+ id;
2111
2114
  type;
2112
2115
  options;
2113
- constructor(message, ddb, type, options) {
2116
+ constructor(message, url, type, options, id) {
2114
2117
  super(message);
2115
- this.ddb = ddb;
2118
+ this.url = url;
2116
2119
  this.type = type;
2117
2120
  this.options = options;
2121
+ this.id = id;
2118
2122
  }
2119
2123
  }
2120
2124
  /** SQL Standrd 标准类型 */
@@ -2242,7 +2246,7 @@ export class DDB {
2242
2246
  throw this.error;
2243
2247
  const { resource: websocket } = this.lwebsocket;
2244
2248
  if (websocket && (websocket.readyState === WebSocket.CLOSING || websocket.readyState === WebSocket.CLOSED))
2245
- throw this.error = new DdbConnectionError(this);
2249
+ throw this.error = new DdbConnectionError(this.url);
2246
2250
  return this.pconnect ??= new Promise(async (resolve, reject) => {
2247
2251
  this.on_error = () => {
2248
2252
  reject(this.error /* 一定有,不需要再 || new DdbConnectionError(this) */);
@@ -2250,23 +2254,18 @@ export class DDB {
2250
2254
  try {
2251
2255
  // 连接建立之前应该不会有别的调用占用 this.lwebsocket
2252
2256
  this.lwebsocket.resource = await connect_websocket(this.url, {
2253
- protocols: (() => {
2254
- if (this.streaming)
2255
- return 'streaming';
2256
- if (this.python)
2257
- return 'python';
2258
- })(),
2257
+ protocols: this.streaming ? ['streaming'] : this.python ? ['python'] : undefined,
2259
2258
  on_message: (buffer, websocket) => {
2260
2259
  this.on_message(buffer, websocket);
2261
2260
  },
2262
2261
  on_error: error => {
2263
- this.error ??= new DdbConnectionError(this, error);
2262
+ this.error ??= new DdbConnectionError(this.url, error);
2264
2263
  this.on_error();
2265
2264
  }
2266
2265
  });
2267
2266
  }
2268
2267
  catch (error) {
2269
- this.error ??= new DdbConnectionError(this, error);
2268
+ this.error ??= new DdbConnectionError(this.url, error);
2270
2269
  reject(this.error);
2271
2270
  return;
2272
2271
  }
@@ -2339,7 +2338,8 @@ export class DDB {
2339
2338
  将这个 flag 设为 true 跳过连接状态检查 */
2340
2339
  async rpc(type, options) {
2341
2340
  // 保留调用栈信息
2342
- let error = new DdbDatabaseError('', this, type, options);
2341
+ const id = genid() % 1000;
2342
+ let error = new DdbDatabaseError('', this.url, type, options, id);
2343
2343
  if (!options.skip_connection_check)
2344
2344
  await this.connect();
2345
2345
  const { script, func, args: _args = [], vars = [], urgent, listener, } = options;
@@ -2398,7 +2398,6 @@ export class DDB {
2398
2398
  if (this.error)
2399
2399
  throw this.error;
2400
2400
  const args = DdbObj.to_ddbobjs(_args);
2401
- const id = genid() % 1000;
2402
2401
  const rpc_id = ` (id = ${id})`;
2403
2402
  const command = this.enc.encode((() => {
2404
2403
  switch (type) {