@dxos/network-manager 0.3.0 → 0.3.1-main.0fddbd4

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.
@@ -61,6 +61,7 @@ export declare class Connection {
61
61
  private readonly _transportFactory;
62
62
  private readonly _callbacks?;
63
63
  private readonly _ctx;
64
+ private connectedTimeoutContext;
64
65
  private _state;
65
66
  private _transport;
66
67
  closeReason?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/swarm/connection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,EAAuB,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAYvC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAahD,UAAU,mBAAmB;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB;;OAEG;IACH,OAAO,YAAY;IAEnB;;;OAGG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,UAAU,eAAe;IAEzB;;OAEG;IACH,SAAS,cAAc;IAEvB;;OAEG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,MAAM,WAAW;IAEjB,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB;AAED;;;GAGG;AACH,qBAAa,UAAU;aAsBH,KAAK,EAAE,SAAS;aAChB,KAAK,EAAE,SAAS;aAChB,QAAQ,EAAE,SAAS;aACnB,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AAW,CAAC,EAAE,MAAM,CAAC;IAErB,OAAO,CAAC,qBAAqB,CAAgB;IAC7C,OAAO,CAAC,qBAAqB,CAAgB;IAE7C,QAAQ,CAAC,YAAY,yBAAgC;IACrD,QAAQ,CAAC,MAAM,cAAqB;IAE7B,WAAW,SAA8B;IAEhD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAE7B;IAEH,OAAO,CAAC,gBAAgB,CAA6B;gBAGnC,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAAE,wBAAwB;IAC1C,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,OAAO,EACjB,gBAAgB,EAAE,eAAe,EACjC,SAAS,EAAE,YAAY,EACvB,iBAAiB,EAAE,gBAAgB,EACnC,UAAU,CAAC,iCAAqB;IAWnD,IAAI,KAAK,oBAER;IAED,IAAI,SAAS,0BAEZ;IAED,IAAI,QAAQ,iBAEX;IAED;;OAEG;IACG,cAAc;IAwFd,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK;IAuCjB,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK;IA0CvB,OAAO,CAAC,WAAW;YAKL,kBAAkB;IAiChC;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,aAAa;IA2B/B,QAAQ;IAIR,OAAO,CAAC,YAAY;CAMrB"}
@@ -84,7 +84,7 @@ export declare class Peer {
84
84
  private _createConnection;
85
85
  closeConnection(err?: Error): Promise<void>;
86
86
  onSignal(message: SignalMessage): Promise<void>;
87
- destroy(): Promise<void>;
87
+ destroy(reason?: Error): Promise<void>;
88
88
  }
89
89
  export {};
90
90
  //# sourceMappingURL=peer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../../../src/swarm/peer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA8B,MAAM,aAAa,CAAC;AAGhE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA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Q,CAAC,MAAM,cAAqB;gBAMjB,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,SAAS,EAC9B,SAAS,EAAE,QAAQ,EACV,iBAAiB,EAAE,oBAAoB,EACvC,UAAU,EAAE,SAAS,EACrB,iBAAiB,EAAE,gBAAgB,EACnC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,kBAAkB,EAAE,iBAAiB,EACrC,gBAAgB,SAAmB;IAkBtD,IAAI,WAAW,iBAId;IAED,IACI,SAAS,cAEZ;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,IACI,KAAK,IAAI,KAAK,CAEjB;IAEK,IAAI;IAaJ,OAAO;IAWP,WAAW,CAAC,QAAQ,EAAE,QAAQ;IAiBpC,YAAY,CAAC,UAAU,EAAE,UAAU;IAgC7B,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB/C,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB/C,SAAS;IAOT,QAAQ;IAId,OAAO,CAAC,gBAAgB;YAmDV,YAAY;IAM1B,OAAO,CAAC,mBAAmB;IAuC3B;;OAEG;YACW,mBAAmB;YA0BnB,gBAAgB;CAQ/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/network-manager",
3
- "version": "0.3.0",
3
+ "version": "0.3.1-main.0fddbd4",
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.0",
35
- "@dxos/codec-protobuf": "0.3.0",
36
- "@dxos/context": "0.3.0",
37
- "@dxos/credentials": "0.3.0",
38
- "@dxos/crypto": "0.3.0",
39
- "@dxos/debug": "0.3.0",
40
- "@dxos/invariant": "0.3.0",
41
- "@dxos/keys": "0.3.0",
42
- "@dxos/log": "0.3.0",
43
- "@dxos/messaging": "0.3.0",
44
- "@dxos/node-std": "0.3.0",
45
- "@dxos/protocols": "0.3.0",
46
- "@dxos/rpc": "0.3.0",
47
- "@dxos/teleport": "0.3.0",
48
- "@dxos/util": "0.3.0"
34
+ "@dxos/async": "0.3.1-main.0fddbd4",
35
+ "@dxos/codec-protobuf": "0.3.1-main.0fddbd4",
36
+ "@dxos/context": "0.3.1-main.0fddbd4",
37
+ "@dxos/credentials": "0.3.1-main.0fddbd4",
38
+ "@dxos/crypto": "0.3.1-main.0fddbd4",
39
+ "@dxos/debug": "0.3.1-main.0fddbd4",
40
+ "@dxos/invariant": "0.3.1-main.0fddbd4",
41
+ "@dxos/keys": "0.3.1-main.0fddbd4",
42
+ "@dxos/log": "0.3.1-main.0fddbd4",
43
+ "@dxos/messaging": "0.3.1-main.0fddbd4",
44
+ "@dxos/node-std": "0.3.1-main.0fddbd4",
45
+ "@dxos/protocols": "0.3.1-main.0fddbd4",
46
+ "@dxos/rpc": "0.3.1-main.0fddbd4",
47
+ "@dxos/teleport": "0.3.1-main.0fddbd4",
48
+ "@dxos/util": "0.3.1-main.0fddbd4"
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.0"
58
+ "@dxos/signal": "0.3.1-main.0fddbd4"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public"
@@ -2,7 +2,7 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { DeferredTask, Event, sleep, synchronized } from '@dxos/async';
5
+ import { DeferredTask, Event, sleep, scheduleTask, synchronized } from '@dxos/async';
6
6
  import { Context, cancelWithContext } from '@dxos/context';
7
7
  import { ErrorStream } from '@dxos/debug';
8
8
  import { invariant } from '@dxos/invariant';
@@ -28,6 +28,11 @@ import { WireProtocol } from '../wire-protocol';
28
28
  */
29
29
  const STARTING_SIGNALLING_DELAY = 10;
30
30
 
31
+ /**
32
+ * How long to wait for the transport to establish connectivity, i.e. for the connection to move between CONNECTING and CONNECTED.
33
+ */
34
+ const TRANSPORT_CONNECTION_TIMEOUT = 10_000;
35
+
31
36
  /**
32
37
  * Maximum delay between signal batches.
33
38
  */
@@ -90,6 +95,7 @@ export enum ConnectionState {
90
95
  */
91
96
  export class Connection {
92
97
  private readonly _ctx = new Context();
98
+ private connectedTimeoutContext = new Context();
93
99
 
94
100
  private _state: ConnectionState = ConnectionState.CREATED;
95
101
  private _transport: Transport | undefined;
@@ -168,6 +174,15 @@ export class Connection {
168
174
  this.close(new ProtocolError('protocol stream closed')).catch((err) => this.errors.raise(err));
169
175
  });
170
176
 
177
+ scheduleTask(
178
+ this.connectedTimeoutContext,
179
+ async () => {
180
+ log.warn('timeout waiting for transport to connect, aborting');
181
+ await this.abort().catch((err) => this.errors.raise(err));
182
+ },
183
+ TRANSPORT_CONNECTION_TIMEOUT,
184
+ );
185
+
171
186
  invariant(!this._transport);
172
187
  this._transport = this._transportFactory.createTransport({
173
188
  initiator: this.initiator,
@@ -175,8 +190,9 @@ export class Connection {
175
190
  sendSignal: async (signal) => this._sendSignal(signal),
176
191
  });
177
192
 
178
- this._transport.connected.once(() => {
193
+ this._transport.connected.once(async () => {
179
194
  this._changeState(ConnectionState.CONNECTED);
195
+ await this.connectedTimeoutContext.dispose();
180
196
  this._callbacks?.onConnected?.();
181
197
  });
182
198
 
@@ -186,7 +202,7 @@ export class Connection {
186
202
  this.abort().catch((err) => this.errors.raise(err));
187
203
  });
188
204
 
189
- this._transport.errors.handle((err) => {
205
+ this._transport.errors.handle(async (err) => {
190
206
  log('transport error:', { err });
191
207
  if (!this.closeReason) {
192
208
  this.closeReason = err?.message;
@@ -204,6 +220,7 @@ export class Connection {
204
220
  }
205
221
 
206
222
  if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
223
+ await this.connectedTimeoutContext.dispose();
207
224
  this.errors.raise(err);
208
225
  }
209
226
  });
@@ -228,6 +245,7 @@ export class Connection {
228
245
  return;
229
246
  }
230
247
 
248
+ await this.connectedTimeoutContext.dispose();
231
249
  this._changeState(ConnectionState.ABORTING);
232
250
  if (!this.closeReason) {
233
251
  this.closeReason = err?.message;
@@ -262,6 +280,8 @@ export class Connection {
262
280
  async close(err?: Error) {
263
281
  if (!this.closeReason) {
264
282
  this.closeReason = err?.message;
283
+ } else {
284
+ this.closeReason += `; ${err?.message}`;
265
285
  }
266
286
  if (
267
287
  this._state === ConnectionState.CLOSED ||
@@ -273,6 +293,7 @@ export class Connection {
273
293
  const lastState = this._state;
274
294
  this._changeState(ConnectionState.CLOSING);
275
295
 
296
+ await this.connectedTimeoutContext.dispose();
276
297
  await this._ctx.dispose();
277
298
 
278
299
  log('closing...', { peerId: this.ownId });
@@ -325,7 +346,8 @@ export class Connection {
325
346
  data: { signalBatch: { signals } },
326
347
  });
327
348
  } catch (err) {
328
- if (err instanceof CancelledError) {
349
+ // TODO(nf): determine why instanceof doesn't work here
350
+ if (err instanceof CancelledError || (err instanceof Error && err.message?.includes('CANCELLED'))) {
329
351
  return;
330
352
  }
331
353
 
package/src/swarm/peer.ts CHANGED
@@ -7,7 +7,7 @@ import { Context } from '@dxos/context';
7
7
  import { invariant } from '@dxos/invariant';
8
8
  import { PublicKey } from '@dxos/keys';
9
9
  import { log } from '@dxos/log';
10
- import { CancelledError, SystemError, TimeoutError } from '@dxos/protocols';
10
+ import { CancelledError, SystemError } from '@dxos/protocols';
11
11
  import { Answer } from '@dxos/protocols/proto/dxos/mesh/swarm';
12
12
 
13
13
  import { Connection, ConnectionState } from './connection';
@@ -108,7 +108,10 @@ export class Peer {
108
108
  async onOffer(message: OfferMessage): Promise<Answer> {
109
109
  const remoteId = message.author;
110
110
 
111
- if (this.connection && ![ConnectionState.CREATED, ConnectionState.INITIAL].includes(this.connection.state)) {
111
+ if (
112
+ this.connection &&
113
+ ![ConnectionState.CREATED, ConnectionState.INITIAL, ConnectionState.CONNECTING].includes(this.connection.state)
114
+ ) {
112
115
  log.info(`received offer when connection already in ${this.connection.state} state`);
113
116
  return { accept: false };
114
117
  }
@@ -173,11 +176,12 @@ export class Peer {
173
176
  const connection = this._createConnection(true, sessionId);
174
177
  this.initiating = true;
175
178
 
179
+ let answer: Answer;
176
180
  try {
177
181
  await this._connectionLimiter.connecting(sessionId);
178
182
  connection.initiate();
179
183
 
180
- const answer = await this._signalMessaging.offer({
184
+ answer = await this._signalMessaging.offer({
181
185
  author: this.localPeerId,
182
186
  recipient: this.id,
183
187
  sessionId,
@@ -189,19 +193,45 @@ export class Peer {
189
193
  log('ignoring response');
190
194
  return;
191
195
  }
196
+ } catch (err: any) {
197
+ log('initiation error: send offer', { err, topic: this.topic, peerId: this.localPeerId, remoteId: this.id });
198
+ await connection.abort(err);
199
+ throw err;
200
+ } finally {
201
+ this.initiating = false;
202
+ }
192
203
 
204
+ try {
193
205
  if (!answer.accept) {
194
206
  this._callbacks.onRejected();
195
207
  return;
196
208
  }
209
+ } catch (err: any) {
210
+ log('initiation error: accept answer', {
211
+ err,
212
+ topic: this.topic,
213
+ peerId: this.localPeerId,
214
+ remoteId: this.id,
215
+ });
216
+ await connection.abort(err);
217
+ throw err;
218
+ } finally {
219
+ this.initiating = false;
220
+ }
221
+
222
+ try {
223
+ log('opening connection as initiator');
197
224
  await connection.openConnection();
198
225
  this._callbacks.onAccepted();
199
226
  } catch (err: any) {
200
- log('initiation error', { err, topic: this.topic, peerId: this.localPeerId, remoteId: this.id });
201
- if (err instanceof TimeoutError) {
202
- log.warn('aborting connection due to signalling failure');
203
- await connection.abort(err);
204
- }
227
+ log('initiation error: open connection', {
228
+ err,
229
+ topic: this.topic,
230
+ peerId: this.localPeerId,
231
+ remoteId: this.id,
232
+ });
233
+ // TODO(nf): unsure when this will be called and the connection won't abort itself. but if it does fall through we should probably abort and not close.
234
+ log.warn('closing connection due to unhandled error on openConnection', { err });
205
235
  // Calls `onStateChange` with CLOSED state.
206
236
  await this.closeConnection(err);
207
237
  throw err;
@@ -297,7 +327,13 @@ export class Peer {
297
327
  this._connectionCtx = this._ctx.derive();
298
328
 
299
329
  connection.errors.handle((err) => {
300
- log.warn('connection error', { topic: this.topic, peerId: this.localPeerId, remoteId: this.id, initiator, err });
330
+ log.warn('connection error, closing', {
331
+ topic: this.topic,
332
+ peerId: this.localPeerId,
333
+ remoteId: this.id,
334
+ initiator,
335
+ err,
336
+ });
301
337
  log.trace('dxos.mesh.connection.error', {
302
338
  topic: this.topic,
303
339
  localPeerId: this.localPeerId,
@@ -342,12 +378,12 @@ export class Peer {
342
378
  }
343
379
 
344
380
  @synchronized
345
- async destroy() {
381
+ async destroy(reason?: Error) {
346
382
  await this._ctx.dispose();
347
383
  log('Destroying peer', { peerId: this.id, topic: this.topic });
348
384
 
349
385
  // Won't throw.
350
- await this?.connection?.close();
386
+ await this?.connection?.close(reason);
351
387
  }
352
388
  }
353
389
 
@@ -144,7 +144,7 @@ export class Swarm {
144
144
 
145
145
  await this._ctx.dispose();
146
146
  await this._topology.destroy();
147
- await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
147
+ await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key, 'swarm destroyed')));
148
148
  log('destroyed');
149
149
  }
150
150
 
@@ -186,8 +186,10 @@ export class Swarm {
186
186
  peer.advertizing = false;
187
187
  if (peer.connection?.state !== ConnectionState.CONNECTED) {
188
188
  // Destroy peer only if there is no p2p-connection established
189
- void this._destroyPeer(peer.id).catch((err) => log.catch(err));
189
+ void this._destroyPeer(peer.id, 'peer left').catch((err) => log.catch(err));
190
190
  }
191
+ } else {
192
+ log('received peerLeft but no peer found', { peer: swarmEvent.peerLeft.peer });
191
193
  }
192
194
  }
193
195
 
@@ -240,7 +242,7 @@ export class Swarm {
240
242
  @synchronized
241
243
  async goOffline() {
242
244
  await this._ctx.dispose();
243
- await Promise.all([...this._peers.keys()].map((peerId) => this._destroyPeer(peerId)));
245
+ await Promise.all([...this._peers.keys()].map((peerId) => this._destroyPeer(peerId, 'goOffline')));
244
246
  }
245
247
 
246
248
  // For debug purposes
@@ -269,7 +271,7 @@ export class Swarm {
269
271
  },
270
272
  onDisconnected: async () => {
271
273
  if (!peer!.advertizing) {
272
- await this._destroyPeer(peer!.id);
274
+ await this._destroyPeer(peer!.id, 'peer disconnected');
273
275
  }
274
276
 
275
277
  this.disconnected.emit(peerId);
@@ -279,7 +281,8 @@ export class Swarm {
279
281
  // If the peer rejected our connection remove it from the set of candidates.
280
282
  // TODO(dmaretskyi): Set flag instead.
281
283
  if (this._peers.has(peerId)) {
282
- void this._destroyPeer(peerId);
284
+ log('peer rejected connection', { peerId });
285
+ void this._destroyPeer(peerId, 'peer rejected connection');
283
286
  }
284
287
  },
285
288
  onAccepted: () => {
@@ -299,9 +302,9 @@ export class Swarm {
299
302
  return peer;
300
303
  }
301
304
 
302
- private async _destroyPeer(peerId: PublicKey) {
305
+ private async _destroyPeer(peerId: PublicKey, reason?: string) {
303
306
  invariant(this._peers.has(peerId));
304
- await this._peers.get(peerId)!.destroy();
307
+ await this._peers.get(peerId)!.destroy(new Error(reason));
305
308
  this._peers.delete(peerId);
306
309
  }
307
310