dolphindb 2.0.1012 → 2.0.1013
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 -3
- package/browser.js +8 -9
- package/browser.js.map +1 -1
- package/index.d.ts +1 -3
- package/index.js +8 -9
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/test.js +14 -0
- package/test.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -427,8 +427,7 @@ export declare class DDB {
|
|
|
427
427
|
pnode_run_defined: boolean;
|
|
428
428
|
/** 在 websocket 收到的第一个 error 时,
|
|
429
429
|
在 connect_websocket 的 on_error 回调中构造 DdbConnectionError 并保存到 DDB 对象上,
|
|
430
|
-
这个 error 的错误信息最准确
|
|
431
|
-
this.errored 为 true 时建议 throw this.error || new DdbConnectionError(this) */
|
|
430
|
+
这个 error 的错误信息最准确 */
|
|
432
431
|
error: DdbConnectionError;
|
|
433
432
|
/** DdbMessage listeners */
|
|
434
433
|
listeners: DdbMessageListener[];
|
|
@@ -437,7 +436,6 @@ export declare class DDB {
|
|
|
437
436
|
/** 首次定义 pnode_run 的 promise,保证并发调用 rpc 时只定义一次 pnode_run */
|
|
438
437
|
ppnode_run: Promise<DdbVoid>;
|
|
439
438
|
get connected(): boolean;
|
|
440
|
-
get errored(): boolean;
|
|
441
439
|
/**
|
|
442
440
|
使用 WebSocket URL 初始化连接到 DolphinDB 的实例(不建立实际的网络连接)
|
|
443
441
|
Initialize an instance of DolphinDB Client using the WebSocket URL (without establishing an actual network connection)
|
package/index.js
CHANGED
|
@@ -2162,8 +2162,7 @@ export class DDB {
|
|
|
2162
2162
|
pnode_run_defined = false;
|
|
2163
2163
|
/** 在 websocket 收到的第一个 error 时,
|
|
2164
2164
|
在 connect_websocket 的 on_error 回调中构造 DdbConnectionError 并保存到 DDB 对象上,
|
|
2165
|
-
这个 error 的错误信息最准确
|
|
2166
|
-
this.errored 为 true 时建议 throw this.error || new DdbConnectionError(this) */
|
|
2165
|
+
这个 error 的错误信息最准确 */
|
|
2167
2166
|
error;
|
|
2168
2167
|
/** DdbMessage listeners */
|
|
2169
2168
|
listeners = [];
|
|
@@ -2174,9 +2173,6 @@ export class DDB {
|
|
|
2174
2173
|
get connected() {
|
|
2175
2174
|
return !this.error && this.lwebsocket.resource?.readyState === WebSocketOpen;
|
|
2176
2175
|
}
|
|
2177
|
-
get errored() {
|
|
2178
|
-
return Boolean(this.error || (this.lwebsocket.resource && this.lwebsocket.resource.readyState !== WebSocketOpen));
|
|
2179
|
-
}
|
|
2180
2176
|
/**
|
|
2181
2177
|
使用 WebSocket URL 初始化连接到 DolphinDB 的实例(不建立实际的网络连接)
|
|
2182
2178
|
Initialize an instance of DolphinDB Client using the WebSocket URL (without establishing an actual network connection)
|
|
@@ -2239,10 +2235,13 @@ export class DDB {
|
|
|
2239
2235
|
2. The session is stateful, and the previous state cannot be restored even after reconnection
|
|
2240
2236
|
3. After disconnection, all previous ddb.call, ddb.eval should throw a connection error */
|
|
2241
2237
|
async connect() {
|
|
2242
|
-
if (this.errored)
|
|
2243
|
-
throw this.error || new DdbConnectionError(this);
|
|
2244
2238
|
if (this.connected)
|
|
2245
2239
|
return;
|
|
2240
|
+
if (this.error)
|
|
2241
|
+
throw this.error;
|
|
2242
|
+
const { resource: websocket } = this.lwebsocket;
|
|
2243
|
+
if (websocket && (websocket.readyState === WebSocketClosing || websocket.readyState === WebSocketClosed))
|
|
2244
|
+
throw this.error = new DdbConnectionError(this);
|
|
2246
2245
|
return this.pconnect ??= new Promise(async (resolve, reject) => {
|
|
2247
2246
|
this.on_error = () => {
|
|
2248
2247
|
reject(this.error /* 一定有,不需要再 || new DdbConnectionError(this) */);
|
|
@@ -2395,8 +2394,8 @@ export class DDB {
|
|
|
2395
2394
|
// 这里也乐观的认为 this.connected && !this.errored 为 true
|
|
2396
2395
|
return this.lwebsocket.request(async (websocket) => {
|
|
2397
2396
|
// 独占资源后先检查状态
|
|
2398
|
-
if (this.
|
|
2399
|
-
throw this.error
|
|
2397
|
+
if (this.error)
|
|
2398
|
+
throw this.error;
|
|
2400
2399
|
const args = DdbObj.to_ddbobjs(_args);
|
|
2401
2400
|
const id = genid() % 1000;
|
|
2402
2401
|
const rpc_id = ` (id = ${id})`;
|