@dxos/network-manager 0.3.4 → 0.3.5-main.1429e83

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.
@@ -1 +1 @@
1
- {"version":3,"file":"memory-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/memory-transport.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAW,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAGpE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkB3F,eAAO,MAAM,sBAAsB,EAAE,gBAEpC,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAuBnC,OAAO,CAAC,QAAQ,CAAC,OAAO;IArBpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAA8D;IAElG,SAAgB,MAAM,cAAqB;IAC3C,SAAgB,SAAS,cAAqB;IAC9C,SAAgB,MAAM,cAAqB;IAG3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsB;IAElD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAE5E,OAAO,CAAC,UAAU,CAAS;IAG3B,OAAO,CAAC,iBAAiB,CAAa;IAEtC,OAAO,CAAC,iBAAiB,CAAC,CAAkB;gBAEf,OAAO,EAAE,gBAAgB;IA4DhD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B9B,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM;CAY3B"}
1
+ {"version":3,"file":"memory-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/memory-transport.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAW,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAGpE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkB3F,eAAO,MAAM,sBAAsB,EAAE,gBAEpC,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAuBnC,OAAO,CAAC,QAAQ,CAAC,OAAO;IArBpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAA8D;IAElG,SAAgB,MAAM,cAAqB;IAC3C,SAAgB,SAAS,cAAqB;IAC9C,SAAgB,MAAM,cAAqB;IAG3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsB;IAElD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAE5E,OAAO,CAAC,UAAU,CAAS;IAG3B,OAAO,CAAC,iBAAiB,CAAa;IAEtC,OAAO,CAAC,iBAAiB,CAAC,CAAkB;gBAEf,OAAO,EAAE,gBAAgB;IA4DhD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkC9B,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM;CAY3B"}
@@ -14,6 +14,7 @@ export declare class SimplePeerTransportProxy implements Transport {
14
14
  private readonly _params;
15
15
  private readonly _proxyId;
16
16
  private readonly _ctx;
17
+ private _timeoutCount;
17
18
  readonly closed: Event<void>;
18
19
  readonly connected: Event<void>;
19
20
  readonly errors: ErrorStream;
@@ -1 +1 @@
1
- {"version":3,"file":"simplepeer-transport-proxy.d.ts","sourceRoot":"","sources":["../../../../src/transport/simplepeer-transport-proxy.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,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB9B;;OAEG;IAEH,UAAU;CAKX;AAGD,qBAAa,+BAAgC,YAAW,gBAAgB;IACtE,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,YAAY,CAAuC;IAE3D;;;OAGG;IACH,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI;IAShE,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS;CAatD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/network-manager",
3
- "version": "0.3.4",
3
+ "version": "0.3.5-main.1429e83",
4
4
  "description": "Network Manager",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -31,21 +31,21 @@
31
31
  "tiny-invariant": "^1.3.1",
32
32
  "ws": "^7.4.4",
33
33
  "xor-distance": "^2.0.0",
34
- "@dxos/async": "0.3.4",
35
- "@dxos/codec-protobuf": "0.3.4",
36
- "@dxos/context": "0.3.4",
37
- "@dxos/credentials": "0.3.4",
38
- "@dxos/crypto": "0.3.4",
39
- "@dxos/debug": "0.3.4",
40
- "@dxos/invariant": "0.3.4",
41
- "@dxos/keys": "0.3.4",
42
- "@dxos/log": "0.3.4",
43
- "@dxos/messaging": "0.3.4",
44
- "@dxos/node-std": "0.3.4",
45
- "@dxos/protocols": "0.3.4",
46
- "@dxos/rpc": "0.3.4",
47
- "@dxos/teleport": "0.3.4",
48
- "@dxos/util": "0.3.4"
34
+ "@dxos/async": "0.3.5-main.1429e83",
35
+ "@dxos/codec-protobuf": "0.3.5-main.1429e83",
36
+ "@dxos/context": "0.3.5-main.1429e83",
37
+ "@dxos/credentials": "0.3.5-main.1429e83",
38
+ "@dxos/crypto": "0.3.5-main.1429e83",
39
+ "@dxos/debug": "0.3.5-main.1429e83",
40
+ "@dxos/invariant": "0.3.5-main.1429e83",
41
+ "@dxos/keys": "0.3.5-main.1429e83",
42
+ "@dxos/log": "0.3.5-main.1429e83",
43
+ "@dxos/messaging": "0.3.5-main.1429e83",
44
+ "@dxos/node-std": "0.3.5-main.1429e83",
45
+ "@dxos/protocols": "0.3.5-main.1429e83",
46
+ "@dxos/rpc": "0.3.5-main.1429e83",
47
+ "@dxos/teleport": "0.3.5-main.1429e83",
48
+ "@dxos/util": "0.3.5-main.1429e83"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@swc-node/register": "1.5.4",
@@ -55,7 +55,7 @@
55
55
  "earljs": "~0.1.10",
56
56
  "fast-check": "~3.3.0",
57
57
  "typescript": "^5.2.2",
58
- "@dxos/signal": "0.3.4"
58
+ "@dxos/signal": "0.3.5-main.1429e83"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public"
@@ -353,7 +353,7 @@ export class Connection {
353
353
 
354
354
  // If signal fails treat connection as failed
355
355
  log.info('signal message failed to deliver', { err });
356
- await this.close();
356
+ await this.close(new ConnectivityError('signal message failed to deliver', err));
357
357
  }
358
358
  }
359
359
 
@@ -138,8 +138,11 @@ export class MemoryTransport implements Transport {
138
138
  // code .unpipe(this._incomingDelay)
139
139
  // code .unpipe(this._stream);
140
140
 
141
- this._outgoingDelay.unpipe();
142
- this._incomingDelay.unpipe();
141
+ this.options.stream.unpipe(this._incomingDelay);
142
+ this._incomingDelay.unpipe(this._remoteConnection.options.stream);
143
+ this._remoteConnection.options.stream.unpipe(this._outgoingDelay);
144
+ this._outgoingDelay.unpipe(this.options.stream);
145
+ this.options.stream.unpipe(this._outgoingDelay);
143
146
 
144
147
  this._remoteConnection.closed.emit();
145
148
  this._remoteConnection._remoteConnection = undefined;
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { Writable } from 'node:stream';
6
6
 
7
- import { Event } from '@dxos/async';
7
+ import { Event, scheduleTask } from '@dxos/async';
8
8
  import { type Stream } from '@dxos/codec-protobuf';
9
9
  import { Context } from '@dxos/context';
10
10
  import { ErrorStream } from '@dxos/debug';
@@ -24,6 +24,9 @@ import { arrayToBuffer } from '@dxos/util';
24
24
 
25
25
  import { type Transport, type TransportFactory, type TransportOptions } from './transport';
26
26
 
27
+ const RESP_MIN_THRESHOLD = 500;
28
+ const TIMEOUT_THRESHOLD = 10;
29
+
27
30
  export type SimplePeerTransportProxyParams = {
28
31
  initiator: boolean;
29
32
  stream: NodeJS.ReadWriteStream;
@@ -35,6 +38,7 @@ export type SimplePeerTransportProxyParams = {
35
38
  export class SimplePeerTransportProxy implements Transport {
36
39
  private readonly _proxyId = PublicKey.random();
37
40
  private readonly _ctx = new Context();
41
+ private _timeoutCount = 0;
38
42
 
39
43
  readonly closed = new Event();
40
44
  readonly connected = new Event();
@@ -62,23 +66,45 @@ export class SimplePeerTransportProxy implements Transport {
62
66
  }
63
67
  });
64
68
 
65
- this._params.stream.pipe(
66
- new Writable({
67
- write: (chunk, _, callback) => {
68
- this._params.bridgeService
69
- .sendData({
70
- proxyId: this._proxyId,
71
- payload: chunk,
72
- })
73
- .then(
74
- () => callback(),
75
- (err: any) => {
69
+ const proxyStream = new Writable({
70
+ write: (chunk, _, callback) => {
71
+ const then = performance.now();
72
+ this._params.bridgeService
73
+ .sendData({
74
+ proxyId: this._proxyId,
75
+ payload: chunk,
76
+ })
77
+ .then(
78
+ () => {
79
+ if (performance.now() - then > RESP_MIN_THRESHOLD) {
80
+ log('slow response, delaying callback');
81
+ scheduleTask(this._ctx, () => callback(), RESP_MIN_THRESHOLD);
82
+ } else {
83
+ callback();
84
+ }
85
+ this._timeoutCount = 0;
86
+ },
87
+ (err: any) => {
88
+ if (err instanceof TimeoutError || err.constructor.name === 'TimeoutError') {
89
+ if (this._timeoutCount++ > TIMEOUT_THRESHOLD) {
90
+ throw new TimeoutError(`too many timeoutes (${this._timeoutCount} > ${TIMEOUT_THRESHOLD}`);
91
+ } else {
92
+ log('timeout error, but still invoking callback');
93
+ callback();
94
+ }
95
+ } else {
76
96
  log.catch(err);
77
- },
78
- );
79
- },
80
- }),
81
- );
97
+ }
98
+ },
99
+ );
100
+ },
101
+ });
102
+
103
+ proxyStream.on('error', (err) => {
104
+ log('proxystream error', { err });
105
+ });
106
+
107
+ this._params.stream.pipe(proxyStream);
82
108
  },
83
109
  (error) => log.catch(error),
84
110
  );