@dxos/network-manager 0.1.58-main.385b5e4 → 0.1.58-main.3c4b26c

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.
@@ -197,7 +197,7 @@ var Connection = class {
197
197
  this.closeReason = err?.message;
198
198
  }
199
199
  if (err instanceof ConnectionResetError) {
200
- log("aborting due to transport ConnectionResetError", void 0, {
200
+ log.warn("aborting due to transport ConnectionResetError", void 0, {
201
201
  F: __dxlog_file,
202
202
  L: 197,
203
203
  S: this,
@@ -205,7 +205,7 @@ var Connection = class {
205
205
  });
206
206
  this.abort().catch((err2) => this.errors.raise(err2));
207
207
  } else if (err instanceof ConnectivityError) {
208
- log("aborting due to transport ConnectivityError", void 0, {
208
+ log.warn("aborting due to transport ConnectivityError", void 0, {
209
209
  F: __dxlog_file,
210
210
  L: 200,
211
211
  S: this,
@@ -213,7 +213,7 @@ var Connection = class {
213
213
  });
214
214
  this.abort().catch((err2) => this.errors.raise(err2));
215
215
  } else if (err instanceof UnknownProtocolError) {
216
- log("unsure what to do for UnknownProtocolError", {
216
+ log.warn("unsure what to do with UnknownProtocolError, will keep on truckin", {
217
217
  err
218
218
  }, {
219
219
  F: __dxlog_file,
@@ -244,14 +244,14 @@ var Connection = class {
244
244
  err
245
245
  }, {
246
246
  F: __dxlog_file,
247
- L: 224,
247
+ L: 225,
248
248
  S: this,
249
249
  C: (f, a) => f(...a)
250
250
  });
251
251
  if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
252
252
  log(`abort ignored: already ${this._state}`, this.closeReason, {
253
253
  F: __dxlog_file,
254
- L: 226,
254
+ L: 227,
255
255
  S: this,
256
256
  C: (f, a) => f(...a)
257
257
  });
@@ -267,7 +267,7 @@ var Connection = class {
267
267
  proto: this._protocol
268
268
  }, {
269
269
  F: __dxlog_file,
270
- L: 239,
270
+ L: 240,
271
271
  S: this,
272
272
  C: (f, a) => f(...a)
273
273
  });
@@ -275,7 +275,7 @@ var Connection = class {
275
275
  } catch (err2) {
276
276
  log.catch(err2, void 0, {
277
277
  F: __dxlog_file,
278
- L: 242,
278
+ L: 243,
279
279
  S: this,
280
280
  C: (f, a) => f(...a)
281
281
  });
@@ -285,7 +285,7 @@ var Connection = class {
285
285
  } catch (err2) {
286
286
  log.catch(err2, void 0, {
287
287
  F: __dxlog_file,
288
- L: 249,
288
+ L: 250,
289
289
  S: this,
290
290
  C: (f, a) => f(...a)
291
291
  });
@@ -295,7 +295,7 @@ var Connection = class {
295
295
  } catch (err2) {
296
296
  log.catch(err2, void 0, {
297
297
  F: __dxlog_file,
298
- L: 255,
298
+ L: 256,
299
299
  S: this,
300
300
  C: (f, a) => f(...a)
301
301
  });
@@ -316,7 +316,7 @@ var Connection = class {
316
316
  peerId: this.ownId
317
317
  }, {
318
318
  F: __dxlog_file,
319
- L: 277,
319
+ L: 278,
320
320
  S: this,
321
321
  C: (f, a) => f(...a)
322
322
  });
@@ -326,7 +326,7 @@ var Connection = class {
326
326
  } catch (err2) {
327
327
  log.catch(err2, void 0, {
328
328
  F: __dxlog_file,
329
- L: 284,
329
+ L: 285,
330
330
  S: this,
331
331
  C: (f, a) => f(...a)
332
332
  });
@@ -336,7 +336,7 @@ var Connection = class {
336
336
  } catch (err2) {
337
337
  log.catch(err2, void 0, {
338
338
  F: __dxlog_file,
339
- L: 291,
339
+ L: 292,
340
340
  S: this,
341
341
  C: (f, a) => f(...a)
342
342
  });
@@ -346,7 +346,7 @@ var Connection = class {
346
346
  peerId: this.ownId
347
347
  }, {
348
348
  F: __dxlog_file,
349
- L: 295,
349
+ L: 296,
350
350
  S: this,
351
351
  C: (f, a) => f(...a)
352
352
  });
@@ -389,7 +389,7 @@ var Connection = class {
389
389
  err
390
390
  }, {
391
391
  F: __dxlog_file,
392
- L: 332,
392
+ L: 333,
393
393
  S: this,
394
394
  C: (f, a) => f(...a)
395
395
  });
@@ -402,7 +402,7 @@ var Connection = class {
402
402
  async signal(msg) {
403
403
  invariant(msg.sessionId, void 0, {
404
404
  F: __dxlog_file,
405
- L: 341,
405
+ L: 342,
406
406
  S: this,
407
407
  A: [
408
408
  "msg.sessionId",
@@ -412,7 +412,7 @@ var Connection = class {
412
412
  if (!msg.sessionId.equals(this.sessionId)) {
413
413
  log("dropping signal for incorrect session id", void 0, {
414
414
  F: __dxlog_file,
415
- L: 343,
415
+ L: 344,
416
416
  S: this,
417
417
  C: (f, a) => f(...a)
418
418
  });
@@ -420,7 +420,7 @@ var Connection = class {
420
420
  }
421
421
  invariant(msg.data.signal || msg.data.signalBatch, void 0, {
422
422
  F: __dxlog_file,
423
- L: 346,
423
+ L: 347,
424
424
  S: this,
425
425
  A: [
426
426
  "msg.data.signal || msg.data.signalBatch",
@@ -429,7 +429,7 @@ var Connection = class {
429
429
  });
430
430
  invariant(msg.author?.equals(this.remoteId), void 0, {
431
431
  F: __dxlog_file,
432
- L: 347,
432
+ L: 348,
433
433
  S: this,
434
434
  A: [
435
435
  "msg.author?.equals(this.remoteId)",
@@ -438,7 +438,7 @@ var Connection = class {
438
438
  });
439
439
  invariant(msg.recipient?.equals(this.ownId), void 0, {
440
440
  F: __dxlog_file,
441
- L: 348,
441
+ L: 349,
442
442
  S: this,
443
443
  A: [
444
444
  "msg.recipient?.equals(this.ownId)",
@@ -462,7 +462,7 @@ var Connection = class {
462
462
  msg: msg.data
463
463
  }, {
464
464
  F: __dxlog_file,
465
- L: 357,
465
+ L: 358,
466
466
  S: this,
467
467
  C: (f, a) => f(...a)
468
468
  });
@@ -470,7 +470,7 @@ var Connection = class {
470
470
  } else {
471
471
  invariant(this._transport, "Connection not ready to accept signals.", {
472
472
  F: __dxlog_file,
473
- L: 360,
473
+ L: 361,
474
474
  S: this,
475
475
  A: [
476
476
  "this._transport",
@@ -483,7 +483,7 @@ var Connection = class {
483
483
  msg: msg.data
484
484
  }, {
485
485
  F: __dxlog_file,
486
- L: 361,
486
+ L: 362,
487
487
  S: this,
488
488
  C: (f, a) => f(...a)
489
489
  });
@@ -501,13 +501,13 @@ var Connection = class {
501
501
  peerId: this.ownId
502
502
  }, {
503
503
  F: __dxlog_file,
504
- L: 372,
504
+ L: 373,
505
505
  S: this,
506
506
  C: (f, a) => f(...a)
507
507
  });
508
508
  invariant(state !== this._state, "Already in this state.", {
509
509
  F: __dxlog_file,
510
- L: 373,
510
+ L: 374,
511
511
  S: this,
512
512
  A: [
513
513
  "state !== this._state",
@@ -978,6 +978,12 @@ var Peer = class {
978
978
  C: (f, a) => f(...a)
979
979
  });
980
980
  if (err instanceof TimeoutError) {
981
+ log3.warn("aborting connection due to signalling failure", void 0, {
982
+ F: __dxlog_file3,
983
+ L: 202,
984
+ S: this,
985
+ C: (f, a) => f(...a)
986
+ });
981
987
  await connection.abort(err);
982
988
  }
983
989
  await this.closeConnection(err);
@@ -999,13 +1005,13 @@ var Peer = class {
999
1005
  sessionId
1000
1006
  }, {
1001
1007
  F: __dxlog_file3,
1002
- L: 217,
1008
+ L: 218,
1003
1009
  S: this,
1004
1010
  C: (f, a) => f(...a)
1005
1011
  });
1006
1012
  invariant3(!this.connection, "Already connected.", {
1007
1013
  F: __dxlog_file3,
1008
- L: 224,
1014
+ L: 225,
1009
1015
  S: this,
1010
1016
  A: [
1011
1017
  "!this.connection",
@@ -1041,7 +1047,7 @@ var Peer = class {
1041
1047
  initiator
1042
1048
  }, {
1043
1049
  F: __dxlog_file3,
1044
- L: 243,
1050
+ L: 244,
1045
1051
  S: this,
1046
1052
  C: (f, a) => f(...a)
1047
1053
  });
@@ -1054,14 +1060,14 @@ var Peer = class {
1054
1060
  initiator
1055
1061
  }, {
1056
1062
  F: __dxlog_file3,
1057
- L: 252,
1063
+ L: 253,
1058
1064
  S: this,
1059
1065
  C: (f, a) => f(...a)
1060
1066
  });
1061
1067
  this._connectionLimiter.doneConnecting(sessionId);
1062
1068
  invariant3(this.connection === connection, "Connection mismatch (race condition).", {
1063
1069
  F: __dxlog_file3,
1064
- L: 257,
1070
+ L: 258,
1065
1071
  S: this,
1066
1072
  A: [
1067
1073
  "this.connection === connection",
@@ -1076,7 +1082,7 @@ var Peer = class {
1076
1082
  initiator
1077
1083
  }, {
1078
1084
  F: __dxlog_file3,
1079
- L: 259,
1085
+ L: 260,
1080
1086
  S: this,
1081
1087
  C: (f, a) => f(...a)
1082
1088
  });
@@ -1111,7 +1117,7 @@ var Peer = class {
1111
1117
  err
1112
1118
  }, {
1113
1119
  F: __dxlog_file3,
1114
- L: 299,
1120
+ L: 300,
1115
1121
  S: this,
1116
1122
  C: (f, a) => f(...a)
1117
1123
  });
@@ -1124,7 +1130,7 @@ var Peer = class {
1124
1130
  err
1125
1131
  }, {
1126
1132
  F: __dxlog_file3,
1127
- L: 300,
1133
+ L: 301,
1128
1134
  S: this,
1129
1135
  C: (f, a) => f(...a)
1130
1136
  });
@@ -1143,7 +1149,7 @@ var Peer = class {
1143
1149
  sessionId: connection.sessionId
1144
1150
  }, {
1145
1151
  F: __dxlog_file3,
1146
- L: 325,
1152
+ L: 326,
1147
1153
  S: this,
1148
1154
  C: (f, a) => f(...a)
1149
1155
  });
@@ -1153,7 +1159,7 @@ var Peer = class {
1153
1159
  sessionId: connection.sessionId
1154
1160
  }, {
1155
1161
  F: __dxlog_file3,
1156
- L: 331,
1162
+ L: 332,
1157
1163
  S: this,
1158
1164
  C: (f, a) => f(...a)
1159
1165
  });
@@ -1164,7 +1170,7 @@ var Peer = class {
1164
1170
  message
1165
1171
  }, {
1166
1172
  F: __dxlog_file3,
1167
- L: 336,
1173
+ L: 337,
1168
1174
  S: this,
1169
1175
  C: (f, a) => f(...a)
1170
1176
  });
@@ -1179,7 +1185,7 @@ var Peer = class {
1179
1185
  topic: this.topic
1180
1186
  }, {
1181
1187
  F: __dxlog_file3,
1182
- L: 346,
1188
+ L: 347,
1183
1189
  S: this,
1184
1190
  C: (f, a) => f(...a)
1185
1191
  });
@@ -2685,24 +2691,28 @@ var SimplePeerTransport = class {
2685
2691
  switch (err.code) {
2686
2692
  case "ERR_WEBRTC_SUPPORT":
2687
2693
  this.errors.raise(new ProtocolError2("WebRTC not supported", err));
2694
+ break;
2688
2695
  case "ERR_ICE_CONNECTION_FAILURE":
2689
2696
  case "ERR_DATA_CHANNEL":
2690
2697
  case "ERR_CONNECTION_FAILURE":
2691
2698
  case "ERR_SIGNALING":
2692
2699
  this.errors.raise(new ConnectivityError2("unknown communication failure", err));
2700
+ break;
2693
2701
  case "ERR_CREATE_OFFER":
2694
2702
  case "ERR_CREATE_ANSWER":
2695
2703
  case "ERR_SET_LOCAL_DESCRIPTION":
2696
2704
  case "ERR_SET_REMOTE_DESCRIPTION":
2697
2705
  case "ERR_ADD_ICE_CANDIDATE":
2698
2706
  this.errors.raise(new UnknownProtocolError2("unknown simple-peer library failure", err));
2707
+ break;
2699
2708
  default:
2700
2709
  this.errors.raise(new Error("unknown simple-peer error"));
2710
+ break;
2701
2711
  }
2702
2712
  } else {
2703
2713
  log11.info("unknown peer connection error", err, {
2704
2714
  F: __dxlog_file12,
2705
- L: 96,
2715
+ L: 101,
2706
2716
  S: this,
2707
2717
  C: (f, a) => f(...a)
2708
2718
  });
@@ -2716,7 +2726,7 @@ var SimplePeerTransport = class {
2716
2726
  stats
2717
2727
  }, {
2718
2728
  F: __dxlog_file12,
2719
- L: 104,
2729
+ L: 109,
2720
2730
  S: this,
2721
2731
  C: (f, a) => f(...a)
2722
2732
  });
@@ -2725,7 +2735,7 @@ var SimplePeerTransport = class {
2725
2735
  } catch (err2) {
2726
2736
  log11.catch(err2, void 0, {
2727
2737
  F: __dxlog_file12,
2728
- L: 111,
2738
+ L: 116,
2729
2739
  S: this,
2730
2740
  C: (f, a) => f(...a)
2731
2741
  });
@@ -2736,7 +2746,7 @@ var SimplePeerTransport = class {
2736
2746
  id: this._instanceId
2737
2747
  }), {
2738
2748
  F: __dxlog_file12,
2739
- L: 116,
2749
+ L: 121,
2740
2750
  S: this,
2741
2751
  C: (f, a) => f(...a)
2742
2752
  });
@@ -2744,7 +2754,7 @@ var SimplePeerTransport = class {
2744
2754
  async destroy() {
2745
2755
  log11("closing...", void 0, {
2746
2756
  F: __dxlog_file12,
2747
- L: 120,
2757
+ L: 125,
2748
2758
  S: this,
2749
2759
  C: (f, a) => f(...a)
2750
2760
  });
@@ -2754,7 +2764,7 @@ var SimplePeerTransport = class {
2754
2764
  this.closed.emit();
2755
2765
  log11("closed", void 0, {
2756
2766
  F: __dxlog_file12,
2757
- L: 125,
2767
+ L: 130,
2758
2768
  S: this,
2759
2769
  C: (f, a) => f(...a)
2760
2770
  });
@@ -2856,7 +2866,8 @@ var SimplePeerTransportService = class {
2856
2866
  const transportState = {
2857
2867
  transport,
2858
2868
  stream: duplex,
2859
- writeCallbacks: []
2869
+ writeCallbacks: [],
2870
+ state: "OPEN"
2860
2871
  };
2861
2872
  ready();
2862
2873
  this.transports.set(request.proxyId, transportState);
@@ -2866,7 +2877,7 @@ var SimplePeerTransportService = class {
2866
2877
  async sendSignal({ proxyId, signal }) {
2867
2878
  invariant12(this.transports.has(proxyId), void 0, {
2868
2879
  F: __dxlog_file13,
2869
- L: 110,
2880
+ L: 112,
2870
2881
  S: this,
2871
2882
  A: [
2872
2883
  "this.transports.has(proxyId)",
@@ -2876,9 +2887,17 @@ var SimplePeerTransportService = class {
2876
2887
  await this.transports.get(proxyId).transport.signal(signal);
2877
2888
  }
2878
2889
  async sendData({ proxyId, payload }) {
2890
+ if (this.transports.get(proxyId)?.state !== "OPEN") {
2891
+ log12.debug("transport is closed", void 0, {
2892
+ F: __dxlog_file13,
2893
+ L: 118,
2894
+ S: this,
2895
+ C: (f, a) => f(...a)
2896
+ });
2897
+ }
2879
2898
  invariant12(this.transports.has(proxyId), void 0, {
2880
2899
  F: __dxlog_file13,
2881
- L: 115,
2900
+ L: 120,
2882
2901
  S: this,
2883
2902
  A: [
2884
2903
  "this.transports.has(proxyId)",
@@ -2896,10 +2915,12 @@ var SimplePeerTransportService = class {
2896
2915
  async close({ proxyId }) {
2897
2916
  await this.transports.get(proxyId)?.transport.destroy();
2898
2917
  await this.transports.get(proxyId)?.stream.end();
2899
- this.transports.delete(proxyId);
2918
+ if (this.transports.get(proxyId)) {
2919
+ this.transports.get(proxyId).state = "CLOSED";
2920
+ }
2900
2921
  log12("Closed.", void 0, {
2901
2922
  F: __dxlog_file13,
2902
- L: 129,
2923
+ L: 136,
2903
2924
  S: this,
2904
2925
  C: (f, a) => f(...a)
2905
2926
  });
@@ -3465,4 +3486,4 @@ export {
3465
3486
  createLibDataChannelTransportFactory,
3466
3487
  createTeleportProtocolFactory
3467
3488
  };
3468
- //# sourceMappingURL=chunk-JIGWYM5K.mjs.map
3489
+ //# sourceMappingURL=chunk-26KK6XOP.mjs.map