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