xshell 1.0.114 → 1.0.116
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/net.browser.js +13 -5
- package/net.js +13 -5
- package/package.json +1 -1
package/net.browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t } from './i18n/instance.js';
|
|
2
2
|
import './prototype.browser.js'; // to_time_str()
|
|
3
|
-
import { assert, concat, genid, delay, Lock, encode, decode } from './utils.browser.js';
|
|
3
|
+
import { assert, concat, genid, delay, Lock, encode, decode, timeout } from './utils.browser.js';
|
|
4
4
|
const drop_request_headers = new Set([
|
|
5
5
|
// : 开头的 key
|
|
6
6
|
// sec-*
|
|
@@ -290,6 +290,7 @@ export class Remote {
|
|
|
290
290
|
const len_json = dv.getUint32(0, true);
|
|
291
291
|
let offset = 4 + len_json;
|
|
292
292
|
let message = JSON.parse(decode(buffer.subarray(4, offset)));
|
|
293
|
+
message.data ??= [];
|
|
293
294
|
if (message.bins) {
|
|
294
295
|
const { bins } = message;
|
|
295
296
|
let { data } = message;
|
|
@@ -379,11 +380,15 @@ export class Remote {
|
|
|
379
380
|
this.reconnecting = false;
|
|
380
381
|
if (!this.disconnected)
|
|
381
382
|
try {
|
|
382
|
-
await
|
|
383
|
+
await timeout(3000, async () => {
|
|
384
|
+
await this.connect();
|
|
385
|
+
});
|
|
383
386
|
this.first_error = true;
|
|
384
387
|
}
|
|
385
|
-
catch {
|
|
386
|
-
//
|
|
388
|
+
catch (error) {
|
|
389
|
+
// 重连失败的错误这里需要简单打印下,_on_error 不会打印,这里也不继续往上抛了
|
|
390
|
+
console.log(error.message);
|
|
391
|
+
// 重连由 this.connect 里面调用 this._on_error 处理
|
|
387
392
|
}
|
|
388
393
|
})();
|
|
389
394
|
};
|
|
@@ -441,9 +446,12 @@ export class Remote {
|
|
|
441
446
|
break;
|
|
442
447
|
if (!this.reconnecting)
|
|
443
448
|
try {
|
|
444
|
-
await
|
|
449
|
+
await timeout(1000 * 2, async () => {
|
|
450
|
+
await this.call('echo', []);
|
|
451
|
+
});
|
|
445
452
|
}
|
|
446
453
|
catch (error) {
|
|
454
|
+
console.log(error.message);
|
|
447
455
|
this._on_error(error);
|
|
448
456
|
}
|
|
449
457
|
}
|
package/net.js
CHANGED
|
@@ -3,7 +3,7 @@ import { buffer as stream_to_buffer, text as stream_to_text } from 'stream/consu
|
|
|
3
3
|
import { isReadable } from 'stream';
|
|
4
4
|
import { t } from './i18n/instance.js';
|
|
5
5
|
import './prototype.js';
|
|
6
|
-
import { inspect, concat, assert, genid, delay, Lock, encode, decode, pipe_with_error, map_values, unique } from './utils.js';
|
|
6
|
+
import { inspect, concat, assert, genid, delay, Lock, encode, decode, pipe_with_error, map_values, unique, timeout } from './utils.js';
|
|
7
7
|
export const WebSocketConnecting = 0;
|
|
8
8
|
export const WebSocketOpen = 1;
|
|
9
9
|
export const WebSocketClosing = 2;
|
|
@@ -501,6 +501,7 @@ export class Remote {
|
|
|
501
501
|
const len_json = dv.getUint32(0, true);
|
|
502
502
|
let offset = 4 + len_json;
|
|
503
503
|
let message = JSON.parse(decode(buffer.subarray(4, offset)));
|
|
504
|
+
message.data ??= [];
|
|
504
505
|
if (message.bins) {
|
|
505
506
|
const { bins } = message;
|
|
506
507
|
let { data } = message;
|
|
@@ -590,11 +591,15 @@ export class Remote {
|
|
|
590
591
|
this.reconnecting = false;
|
|
591
592
|
if (!this.disconnected)
|
|
592
593
|
try {
|
|
593
|
-
await
|
|
594
|
+
await timeout(3000, async () => {
|
|
595
|
+
await this.connect();
|
|
596
|
+
});
|
|
594
597
|
this.first_error = true;
|
|
595
598
|
}
|
|
596
|
-
catch {
|
|
597
|
-
//
|
|
599
|
+
catch (error) {
|
|
600
|
+
// 重连失败的错误这里需要简单打印下,_on_error 不会打印,这里也不继续往上抛了
|
|
601
|
+
console.log(error.message);
|
|
602
|
+
// 重连由 this.connect 里面调用 this._on_error 处理
|
|
598
603
|
}
|
|
599
604
|
})();
|
|
600
605
|
};
|
|
@@ -652,9 +657,12 @@ export class Remote {
|
|
|
652
657
|
break;
|
|
653
658
|
if (!this.reconnecting)
|
|
654
659
|
try {
|
|
655
|
-
await
|
|
660
|
+
await timeout(1000 * 2, async () => {
|
|
661
|
+
await this.call('echo', []);
|
|
662
|
+
});
|
|
656
663
|
}
|
|
657
664
|
catch (error) {
|
|
665
|
+
console.log(error.message);
|
|
658
666
|
this._on_error(error);
|
|
659
667
|
}
|
|
660
668
|
}
|