dolphindb 2.0.918 → 2.0.919
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 +25 -17
- package/browser.js.map +1 -1
- package/docs.zh.json +17 -33
- package/index.js +25 -17
- package/index.js.map +1 -1
- package/package.json +3 -3
package/browser.js
CHANGED
|
@@ -6,7 +6,7 @@ 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
8
|
import { concat, assert } from 'xshell/utils.browser.js';
|
|
9
|
-
import { connect_websocket } from 'xshell/net.browser.js';
|
|
9
|
+
import { connect_websocket, WebSocketConnectionError } from 'xshell/net.browser.js';
|
|
10
10
|
import { t } from './i18n/index.js';
|
|
11
11
|
export var DdbForm;
|
|
12
12
|
(function (DdbForm) {
|
|
@@ -2125,7 +2125,7 @@ export class DdbConnectionError extends Error {
|
|
|
2125
2125
|
name = 'DdbConnectionError';
|
|
2126
2126
|
ddb;
|
|
2127
2127
|
constructor(ddb, error_options) {
|
|
2128
|
-
super(`${ddb.url} ${t('已断开')}`, error_options);
|
|
2128
|
+
super(`${ddb.url} ${t('已断开')}${error_options?.cause ? `. ${error_options.cause.message}` : ''}`, error_options);
|
|
2129
2129
|
this.ddb = ddb;
|
|
2130
2130
|
}
|
|
2131
2131
|
}
|
|
@@ -2223,7 +2223,7 @@ export class DDB {
|
|
|
2223
2223
|
if (options.streaming !== undefined)
|
|
2224
2224
|
this.streaming = options.streaming;
|
|
2225
2225
|
}
|
|
2226
|
-
on_message(
|
|
2226
|
+
on_message(buffer) {
|
|
2227
2227
|
// 这里的实现一定会被 connect 中的实现覆盖
|
|
2228
2228
|
}
|
|
2229
2229
|
/** 建立实际的 WebSocket 连接到 URL 对应的 DolphinDB Establish a actual websocket connection to the DolphindB corresponding to the URL
|
|
@@ -2240,22 +2240,30 @@ export class DDB {
|
|
|
2240
2240
|
await ptail;
|
|
2241
2241
|
try {
|
|
2242
2242
|
if (!this.connected) {
|
|
2243
|
-
this.on_message =
|
|
2243
|
+
this.on_message = buffer => {
|
|
2244
2244
|
assert(false, t('这是在调用 this.rpc 之前默认的 on_message, 不应该被调用到,除非建立连接后 server 先推送了 message'));
|
|
2245
2245
|
};
|
|
2246
2246
|
this.presult = Promise.resolve(null);
|
|
2247
2247
|
this.pnode_run_defined = false;
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2248
|
+
try {
|
|
2249
|
+
this.websocket = await connect_websocket(this.url, {
|
|
2250
|
+
protocols: (() => {
|
|
2251
|
+
if (this.streaming)
|
|
2252
|
+
return 'streaming';
|
|
2253
|
+
if (this.python)
|
|
2254
|
+
return 'python';
|
|
2255
|
+
})(),
|
|
2256
|
+
on_message: (buffer) => {
|
|
2257
|
+
this.on_message(buffer);
|
|
2258
|
+
}
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
catch (error) {
|
|
2262
|
+
if (error instanceof WebSocketConnectionError)
|
|
2263
|
+
throw new DdbConnectionError(this, { cause: error });
|
|
2264
|
+
else
|
|
2265
|
+
throw error;
|
|
2266
|
+
}
|
|
2259
2267
|
if (this.streaming)
|
|
2260
2268
|
await this.subscribe();
|
|
2261
2269
|
else {
|
|
@@ -2392,7 +2400,7 @@ export class DDB {
|
|
|
2392
2400
|
}
|
|
2393
2401
|
catch { }
|
|
2394
2402
|
// 临界区结束,只有一个 rpc 函数调用运行到这里,可以独占 this.on_message 然后写 WebSocket
|
|
2395
|
-
this.on_message = (
|
|
2403
|
+
this.on_message = (buffer) => {
|
|
2396
2404
|
try {
|
|
2397
2405
|
const buf = new Uint8Array(buffer);
|
|
2398
2406
|
if (this.print_message_buffer)
|
|
@@ -2616,7 +2624,7 @@ export class DDB {
|
|
|
2616
2624
|
segments: [],
|
|
2617
2625
|
};
|
|
2618
2626
|
// 先准备好收到 websocket message 的 callback
|
|
2619
|
-
this.on_message =
|
|
2627
|
+
this.on_message = buffer => {
|
|
2620
2628
|
let { streaming } = this;
|
|
2621
2629
|
try {
|
|
2622
2630
|
const dv = new DataView(buffer);
|