@dxos/echo-pipeline 0.7.4 → 0.7.5-main.9cb18ac

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.
Files changed (39) hide show
  1. package/dist/lib/browser/{chunk-LZK5YFYE.mjs → chunk-KY5AZOEF.mjs} +26 -8
  2. package/dist/lib/browser/{chunk-LZK5YFYE.mjs.map → chunk-KY5AZOEF.mjs.map} +3 -3
  3. package/dist/lib/browser/index.mjs +113 -64
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-MACQJ2EP.cjs → chunk-SXCQEIFA.cjs} +29 -11
  8. package/dist/lib/node/{chunk-MACQJ2EP.cjs.map → chunk-SXCQEIFA.cjs.map} +3 -3
  9. package/dist/lib/node/index.cjs +129 -87
  10. package/dist/lib/node/index.cjs.map +3 -3
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/testing/index.cjs +10 -10
  13. package/dist/lib/node-esm/{chunk-JIZPSASG.mjs → chunk-ZIPZXXS7.mjs} +26 -8
  14. package/dist/lib/node-esm/{chunk-JIZPSASG.mjs.map → chunk-ZIPZXXS7.mjs.map} +3 -3
  15. package/dist/lib/node-esm/index.mjs +113 -64
  16. package/dist/lib/node-esm/index.mjs.map +3 -3
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/testing/index.mjs +1 -1
  19. package/dist/types/src/automerge/automerge-host.d.ts +5 -1
  20. package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
  21. package/dist/types/src/automerge/collection-synchronizer.d.ts +1 -0
  22. package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
  23. package/dist/types/src/automerge/echo-network-adapter.d.ts +1 -0
  24. package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
  25. package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +1 -1
  26. package/dist/types/src/db-host/echo-host.d.ts +3 -2
  27. package/dist/types/src/db-host/echo-host.d.ts.map +1 -1
  28. package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -1
  29. package/dist/types/src/space/space-manager.d.ts +1 -0
  30. package/dist/types/src/space/space-manager.d.ts.map +1 -1
  31. package/dist/types/tsconfig.tsbuildinfo +1 -0
  32. package/package.json +34 -34
  33. package/src/automerge/automerge-host.ts +49 -14
  34. package/src/automerge/collection-synchronizer.ts +8 -4
  35. package/src/automerge/echo-network-adapter.ts +7 -0
  36. package/src/automerge/mesh-echo-replicator.ts +2 -2
  37. package/src/db-host/echo-host.ts +4 -1
  38. package/src/edge/echo-edge-replicator.ts +47 -19
  39. package/src/space/space-manager.ts +17 -1
@@ -21,7 +21,7 @@ import {
21
21
  mapTimeframeToFeedIndexes,
22
22
  startAfter,
23
23
  valueEncoding
24
- } from "./chunk-LZK5YFYE.mjs";
24
+ } from "./chunk-KY5AZOEF.mjs";
25
25
 
26
26
  // packages/core/echo/echo-pipeline/src/db-host/data-service.ts
27
27
  import { UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
@@ -310,7 +310,7 @@ var CollectionSynchronizer = class extends Resource2 {
310
310
  return;
311
311
  }
312
312
  for (const [collectionId, state] of this._perCollectionStates.entries()) {
313
- if (this._shouldSyncCollection(collectionId, peerId)) {
313
+ if (this._activeCollections.has(collectionId) && this._shouldSyncCollection(collectionId, peerId)) {
314
314
  state.interestedPeers.add(peerId);
315
315
  state.lastQueried.set(peerId, Date.now());
316
316
  this._queryCollectionState(collectionId, peerId);
@@ -352,11 +352,18 @@ var CollectionSynchronizer = class extends Resource2 {
352
352
  });
353
353
  validateCollectionState(state);
354
354
  const perCollectionState = this._getOrCreatePerCollectionState(collectionId);
355
- perCollectionState.remoteStates.set(peerId, state);
356
- this.remoteStateUpdated.emit({
357
- peerId,
358
- collectionId
359
- });
355
+ const existingState = perCollectionState.remoteStates.get(peerId) ?? {
356
+ documents: {}
357
+ };
358
+ const diff = diffCollectionState(existingState, state);
359
+ if (diff.missingOnLocal.length > 0 || diff.different.length > 0) {
360
+ perCollectionState.remoteStates.set(peerId, state);
361
+ this.remoteStateUpdated.emit({
362
+ peerId,
363
+ collectionId,
364
+ newDocsAppeared: diff.missingOnLocal.length > 0
365
+ });
366
+ }
360
367
  }
361
368
  _getOrCreatePerCollectionState(collectionId) {
362
369
  return defaultMap(this._perCollectionStates, collectionId, () => ({
@@ -677,6 +684,12 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
677
684
  }
678
685
  this._params.monitor?.recordMessageReceived(message);
679
686
  }
687
+ onConnectionAuthScopeChanged(peer) {
688
+ const entry = this._connections.get(peer);
689
+ if (entry) {
690
+ this._onConnectionAuthScopeChanged(entry.connection);
691
+ }
692
+ }
680
693
  /**
681
694
  * Trigger doc-synchronizer shared documents set recalculation. Happens on peer-candidate.
682
695
  * TODO(y): replace with a proper API call when sharePolicy update becomes supported by automerge-repo
@@ -686,14 +699,14 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
686
699
  peerId: connection.peerId
687
700
  }, {
688
701
  F: __dxlog_file3,
689
- L: 254,
702
+ L: 261,
690
703
  S: this,
691
704
  C: (f, a) => f(...a)
692
705
  });
693
706
  const entry = this._connections.get(connection.peerId);
694
707
  invariant2(entry, void 0, {
695
708
  F: __dxlog_file3,
696
- L: 256,
709
+ L: 263,
697
710
  S: this,
698
711
  A: [
699
712
  "entry",
@@ -710,14 +723,14 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
710
723
  peerId: connection.peerId
711
724
  }, {
712
725
  F: __dxlog_file3,
713
- L: 262,
726
+ L: 269,
714
727
  S: this,
715
728
  C: (f, a) => f(...a)
716
729
  });
717
730
  const entry = this._connections.get(connection.peerId);
718
731
  invariant2(entry, void 0, {
719
732
  F: __dxlog_file3,
720
- L: 264,
733
+ L: 271,
721
734
  S: this,
722
735
  A: [
723
736
  "entry",
@@ -731,13 +744,13 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
731
744
  this._params.monitor?.recordPeerDisconnected(connection.peerId);
732
745
  void entry.reader.cancel().catch((err) => log3.catch(err, void 0, {
733
746
  F: __dxlog_file3,
734
- L: 270,
747
+ L: 277,
735
748
  S: this,
736
749
  C: (f, a) => f(...a)
737
750
  }));
738
751
  void entry.writer.abort().catch((err) => log3.catch(err, void 0, {
739
752
  F: __dxlog_file3,
740
- L: 271,
753
+ L: 278,
741
754
  S: this,
742
755
  C: (f, a) => f(...a)
743
756
  }));
@@ -905,7 +918,7 @@ function _ts_decorate2(decorators, target, key, desc) {
905
918
  }
906
919
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
907
920
  var AutomergeHost = class extends Resource4 {
908
- constructor({ db, indexMetadataStore, dataMonitor, peerIdProvider }) {
921
+ constructor({ db, indexMetadataStore, dataMonitor, peerIdProvider, getSpaceKeyByRootDocumentId }) {
909
922
  super();
910
923
  this._collectionSynchronizer = new CollectionSynchronizer({
911
924
  queryCollectionState: this._queryCollectionState.bind(this),
@@ -934,6 +947,7 @@ var AutomergeHost = class extends Resource4 {
934
947
  });
935
948
  this._indexMetadataStore = indexMetadataStore;
936
949
  this._peerIdProvider = peerIdProvider;
950
+ this._getSpaceKeyByRootDocumentId = getSpaceKeyByRootDocumentId;
937
951
  }
938
952
  async _open() {
939
953
  this._peerId = `host-${this._peerIdProvider?.() ?? PublicKey.random().toHex()}`;
@@ -947,13 +961,22 @@ var AutomergeHost = class extends Resource4 {
947
961
  this._echoNetworkAdapter
948
962
  ]
949
963
  });
950
- Event2.wrap(this._echoNetworkAdapter, "peer-candidate").on(this._ctx, (e) => this._onPeerConnected(e.peerId));
951
- Event2.wrap(this._echoNetworkAdapter, "peer-disconnected").on(this._ctx, (e) => this._onPeerDisconnected(e.peerId));
952
- this._collectionSynchronizer.remoteStateUpdated.on(this._ctx, ({ collectionId, peerId }) => {
964
+ let updatingAuthScope = false;
965
+ Event2.wrap(this._echoNetworkAdapter, "peer-candidate").on(this._ctx, (e) => !updatingAuthScope && this._onPeerConnected(e.peerId));
966
+ Event2.wrap(this._echoNetworkAdapter, "peer-disconnected").on(this._ctx, (e) => !updatingAuthScope && this._onPeerDisconnected(e.peerId));
967
+ this._collectionSynchronizer.remoteStateUpdated.on(this._ctx, ({ collectionId, peerId, newDocsAppeared }) => {
953
968
  this._onRemoteCollectionStateUpdated(collectionId, peerId);
954
969
  this.collectionStateUpdated.emit({
955
970
  collectionId
956
971
  });
972
+ if (newDocsAppeared) {
973
+ updatingAuthScope = true;
974
+ try {
975
+ this._echoNetworkAdapter.onConnectionAuthScopeChanged(peerId);
976
+ } finally {
977
+ updatingAuthScope = false;
978
+ }
979
+ }
957
980
  });
958
981
  await this._echoNetworkAdapter.open();
959
982
  await this._collectionSynchronizer.open();
@@ -1036,7 +1059,7 @@ var AutomergeHost = class extends Resource4 {
1036
1059
  await Promise.all(headsToWait.map(async (entry, index) => {
1037
1060
  const handle = await this.loadDoc(Context.default(void 0, {
1038
1061
  F: __dxlog_file4,
1039
- L: 239
1062
+ L: 264
1040
1063
  }), entry.documentId);
1041
1064
  await waitForHeads(handle, entry.heads);
1042
1065
  }));
@@ -1049,7 +1072,7 @@ var AutomergeHost = class extends Resource4 {
1049
1072
  documentId
1050
1073
  }, {
1051
1074
  F: __dxlog_file4,
1052
- L: 251,
1075
+ L: 276,
1053
1076
  S: this,
1054
1077
  C: (f, a) => f(...a)
1055
1078
  });
@@ -1065,7 +1088,7 @@ var AutomergeHost = class extends Resource4 {
1065
1088
  documentId
1066
1089
  }, {
1067
1090
  F: __dxlog_file4,
1068
- L: 255,
1091
+ L: 280,
1069
1092
  S: this,
1070
1093
  C: (f, a) => f(...a)
1071
1094
  });
@@ -1074,7 +1097,7 @@ var AutomergeHost = class extends Resource4 {
1074
1097
  const doc = handle.docSync();
1075
1098
  invariant3(doc, void 0, {
1076
1099
  F: __dxlog_file4,
1077
- L: 260,
1100
+ L: 285,
1078
1101
  S: this,
1079
1102
  A: [
1080
1103
  "doc",
@@ -1088,7 +1111,7 @@ var AutomergeHost = class extends Resource4 {
1088
1111
  }
1089
1112
  log4.info("done re-indexing heads", void 0, {
1090
1113
  F: __dxlog_file4,
1091
- L: 267,
1114
+ L: 292,
1092
1115
  S: this,
1093
1116
  C: (f, a) => f(...a)
1094
1117
  });
@@ -1172,14 +1195,17 @@ var AutomergeHost = class extends Resource4 {
1172
1195
  }
1173
1196
  async _getContainingSpaceForDocument(documentId) {
1174
1197
  const doc = this._repo.handles[documentId]?.docSync();
1175
- if (!doc) {
1176
- return null;
1198
+ if (doc) {
1199
+ const spaceKeyHex = getSpaceKeyFromDoc(doc);
1200
+ if (spaceKeyHex) {
1201
+ return PublicKey.from(spaceKeyHex);
1202
+ }
1177
1203
  }
1178
- const spaceKeyHex = getSpaceKeyFromDoc(doc);
1179
- if (!spaceKeyHex) {
1180
- return null;
1204
+ const rootDocSpaceKey = this._getSpaceKeyByRootDocumentId?.(documentId);
1205
+ if (rootDocSpaceKey) {
1206
+ return rootDocSpaceKey;
1181
1207
  }
1182
- return PublicKey.from(spaceKeyHex);
1208
+ return null;
1183
1209
  }
1184
1210
  /**
1185
1211
  * Flush documents to disk.
@@ -1293,11 +1319,14 @@ var AutomergeHost = class extends Resource4 {
1293
1319
  if (toReplicate.length === 0) {
1294
1320
  return;
1295
1321
  }
1296
- log4.info("replication documents after collection sync", {
1322
+ log4.info("replicating documents after collection sync", {
1323
+ collectionId,
1324
+ peerId,
1325
+ toReplicate,
1297
1326
  count: toReplicate.length
1298
1327
  }, {
1299
1328
  F: __dxlog_file4,
1300
- L: 499,
1329
+ L: 531,
1301
1330
  S: this,
1302
1331
  C: (f, a) => f(...a)
1303
1332
  });
@@ -1364,7 +1393,7 @@ var changeIsPresentInDoc = (doc, changeHash) => {
1364
1393
  var decodeCollectionState = (state) => {
1365
1394
  invariant3(typeof state === "object" && state !== null, "Invalid state", {
1366
1395
  F: __dxlog_file4,
1367
- L: 557,
1396
+ L: 592,
1368
1397
  S: void 0,
1369
1398
  A: [
1370
1399
  "typeof state === 'object' && state !== null",
@@ -1656,10 +1685,10 @@ var MeshEchoReplicator = class {
1656
1685
  documentId: params.documentId,
1657
1686
  peerId: connection.peerId
1658
1687
  });
1659
- log6("document not found locally for share policy check, accepting the remote document", {
1688
+ log6("document not found locally for share policy check", {
1660
1689
  peerId: connection.peerId,
1661
1690
  documentId: params.documentId,
1662
- remoteDocumentExists
1691
+ acceptDocument: remoteDocumentExists
1663
1692
  }, {
1664
1693
  F: __dxlog_file7,
1665
1694
  L: 91,
@@ -2923,7 +2952,7 @@ var INDEXER_CONFIG = {
2923
2952
  ]
2924
2953
  };
2925
2954
  var EchoHost = class extends Resource9 {
2926
- constructor({ kv, peerIdProvider }) {
2955
+ constructor({ kv, peerIdProvider, getSpaceKeyByRootDocumentId }) {
2927
2956
  super();
2928
2957
  this._spaceStateManager = new SpaceStateManager();
2929
2958
  this._indexMetadataStore = new IndexMetadataStore({
@@ -2934,7 +2963,8 @@ var EchoHost = class extends Resource9 {
2934
2963
  db: kv,
2935
2964
  dataMonitor: this._echoDataMonitor,
2936
2965
  indexMetadataStore: this._indexMetadataStore,
2937
- peerIdProvider
2966
+ peerIdProvider,
2967
+ getSpaceKeyByRootDocumentId
2938
2968
  });
2939
2969
  this._indexer = new Indexer({
2940
2970
  db: kv,
@@ -3059,7 +3089,7 @@ var EchoHost = class extends Resource9 {
3059
3089
  async createSpaceRoot(spaceKey) {
3060
3090
  invariant11(this._lifecycleState === LifecycleState4.OPEN, void 0, {
3061
3091
  F: __dxlog_file15,
3062
- L: 217,
3092
+ L: 220,
3063
3093
  S: this,
3064
3094
  A: [
3065
3095
  "this._lifecycleState === LifecycleState.OPEN",
@@ -3087,7 +3117,7 @@ var EchoHost = class extends Resource9 {
3087
3117
  async openSpaceRoot(spaceId, automergeUrl) {
3088
3118
  invariant11(this._lifecycleState === LifecycleState4.OPEN, void 0, {
3089
3119
  F: __dxlog_file15,
3090
- L: 236,
3120
+ L: 239,
3091
3121
  S: this,
3092
3122
  A: [
3093
3123
  "this._lifecycleState === LifecycleState.OPEN",
@@ -3116,8 +3146,7 @@ var EchoHost = class extends Resource9 {
3116
3146
  };
3117
3147
 
3118
3148
  // packages/core/echo/echo-pipeline/src/edge/echo-edge-replicator.ts
3119
- import { Mutex, scheduleTask as scheduleTask2, scheduleMicroTask } from "@dxos/async";
3120
- import * as A5 from "@dxos/automerge/automerge";
3149
+ import { Mutex, scheduleTask as scheduleTask2, scheduleMicroTask, Trigger as Trigger2 } from "@dxos/async";
3121
3150
  import { cbor as cbor2 } from "@dxos/automerge/automerge-repo";
3122
3151
  import { Context as Context6, Resource as Resource10 } from "@dxos/context";
3123
3152
  import { randomUUID } from "@dxos/crypto";
@@ -3210,14 +3239,14 @@ var EchoEdgeReplicator = class {
3210
3239
  connectedSpaces: this._connectedSpaces.size
3211
3240
  }, {
3212
3241
  F: __dxlog_file16,
3213
- L: 60,
3242
+ L: 59,
3214
3243
  S: this,
3215
3244
  C: (f, a) => f(...a)
3216
3245
  });
3217
3246
  this._context = context;
3218
3247
  this._ctx = Context6.default(void 0, {
3219
3248
  F: __dxlog_file16,
3220
- L: 63
3249
+ L: 62
3221
3250
  });
3222
3251
  this._ctx.onDispose(this._edgeConnection.onReconnected(() => {
3223
3252
  this._ctx && scheduleMicroTask(this._ctx, () => this._handleReconnect());
@@ -3296,7 +3325,7 @@ var EchoEdgeReplicator = class {
3296
3325
  async _openConnection(spaceId, reconnects = 0) {
3297
3326
  invariant12(this._context, void 0, {
3298
3327
  F: __dxlog_file16,
3299
- L: 124,
3328
+ L: 123,
3300
3329
  S: this,
3301
3330
  A: [
3302
3331
  "this._context",
@@ -3305,7 +3334,7 @@ var EchoEdgeReplicator = class {
3305
3334
  });
3306
3335
  invariant12(!this._connections.has(spaceId), void 0, {
3307
3336
  F: __dxlog_file16,
3308
- L: 125,
3337
+ L: 124,
3309
3338
  S: this,
3310
3339
  A: [
3311
3340
  "!this._connections.has(spaceId)",
@@ -3335,7 +3364,7 @@ var EchoEdgeReplicator = class {
3335
3364
  restartDelay
3336
3365
  }, {
3337
3366
  F: __dxlog_file16,
3338
- L: 148,
3367
+ L: 147,
3339
3368
  S: this,
3340
3369
  C: (f, a) => f(...a)
3341
3370
  });
@@ -3366,10 +3395,20 @@ var EchoEdgeReplicator = class {
3366
3395
  await connection.open();
3367
3396
  }
3368
3397
  };
3398
+ var MAX_INFLIGHT_REQUESTS = 5;
3369
3399
  var EdgeReplicatorConnection = class extends Resource10 {
3370
3400
  constructor({ edgeConnection, spaceId, context, sharedPolicyEnabled, onRemoteConnected, onRemoteDisconnected, onRestartRequested }) {
3371
3401
  super();
3372
3402
  this._remotePeerId = null;
3403
+ /**
3404
+ * Prevents sending too many messages to edge over this connection so that we don't overwhelm
3405
+ * a replicator durable object.
3406
+ * inflightRequests counter is incremented on outgoing sync messages and decremented on incoming messages.
3407
+ * The trigger is waiting while the counter is above MAX_INFLIGHT_REQUESTS.
3408
+ * The counter can go negative because we receive edge-initiated sync messages on doc change broadcasts.
3409
+ */
3410
+ this._outgoingRequestsBarrier = new Trigger2();
3411
+ this._inflightRequests = 0;
3373
3412
  this._edgeConnection = edgeConnection;
3374
3413
  this._spaceId = spaceId;
3375
3414
  this._context = context;
@@ -3379,6 +3418,7 @@ var EdgeReplicatorConnection = class extends Resource10 {
3379
3418
  this._onRemoteConnected = onRemoteConnected;
3380
3419
  this._onRemoteDisconnected = onRemoteDisconnected;
3381
3420
  this._onRestartRequested = onRestartRequested;
3421
+ this._outgoingRequestsBarrier.wake();
3382
3422
  this.readable = new ReadableStream({
3383
3423
  start: (controller) => {
3384
3424
  this._readableStreamController = controller;
@@ -3386,6 +3426,11 @@ var EdgeReplicatorConnection = class extends Resource10 {
3386
3426
  });
3387
3427
  this.writable = new WritableStream({
3388
3428
  write: async (message, controller) => {
3429
+ await this._outgoingRequestsBarrier.wait();
3430
+ this._inflightRequests++;
3431
+ if (this._inflightRequests === MAX_INFLIGHT_REQUESTS) {
3432
+ this._outgoingRequestsBarrier.reset();
3433
+ }
3389
3434
  await this._sendMessage(message);
3390
3435
  }
3391
3436
  });
@@ -3393,7 +3438,7 @@ var EdgeReplicatorConnection = class extends Resource10 {
3393
3438
  async _open(ctx) {
3394
3439
  log11("open", void 0, {
3395
3440
  F: __dxlog_file16,
3396
- L: 242,
3441
+ L: 261,
3397
3442
  S: this,
3398
3443
  C: (f, a) => f(...a)
3399
3444
  });
@@ -3405,17 +3450,18 @@ var EdgeReplicatorConnection = class extends Resource10 {
3405
3450
  async _close() {
3406
3451
  log11("close", void 0, {
3407
3452
  F: __dxlog_file16,
3408
- L: 254,
3453
+ L: 273,
3409
3454
  S: this,
3410
3455
  C: (f, a) => f(...a)
3411
3456
  });
3412
3457
  this._readableStreamController.close();
3458
+ this._outgoingRequestsBarrier.throw(new Error("Connection closed."));
3413
3459
  await this._onRemoteDisconnected();
3414
3460
  }
3415
3461
  get peerId() {
3416
3462
  invariant12(this._remotePeerId, "Not connected", {
3417
3463
  F: __dxlog_file16,
3418
- L: 260,
3464
+ L: 282,
3419
3465
  S: this,
3420
3466
  A: [
3421
3467
  "this._remotePeerId",
@@ -3434,12 +3480,13 @@ var EdgeReplicatorConnection = class extends Resource10 {
3434
3480
  documentId: params.documentId,
3435
3481
  peerId: this._remotePeerId
3436
3482
  });
3437
- log11.info("document not found locally for share policy check, accepting the remote document", {
3483
+ log11.verbose("edge-replicator document not found locally for share policy check", {
3438
3484
  documentId: params.documentId,
3439
- remoteDocumentExists
3485
+ acceptDocument: remoteDocumentExists,
3486
+ remoteId: this._remotePeerId
3440
3487
  }, {
3441
3488
  F: __dxlog_file16,
3442
- L: 275,
3489
+ L: 297,
3443
3490
  S: this,
3444
3491
  C: (f, a) => f(...a)
3445
3492
  });
@@ -3452,23 +3499,20 @@ var EdgeReplicatorConnection = class extends Resource10 {
3452
3499
  return true;
3453
3500
  }
3454
3501
  const spaceId = getSpaceIdFromCollectionId(params.collectionId);
3455
- return spaceId === this._spaceId;
3502
+ return spaceId === this._spaceId && params.collectionId.split(":").length === 3;
3456
3503
  }
3457
3504
  _onMessage(message) {
3458
3505
  if (message.serviceId !== this._targetServiceId) {
3459
3506
  return;
3460
3507
  }
3461
3508
  const payload = cbor2.decode(message.payload.value);
3462
- log11("recv", () => {
3463
- const decodedData = payload.type === "sync" && payload.data ? A5.decodeSyncMessage(payload.data) : payload.type === "collection-state" ? payload.state : payload;
3464
- return {
3465
- from: message.serviceId,
3466
- type: payload.type,
3467
- decodedData
3468
- };
3509
+ log11.verbose("edge replicator receive", {
3510
+ type: payload.type,
3511
+ documentId: payload.type === "sync" && payload.documentId,
3512
+ remoteId: this._remotePeerId
3469
3513
  }, {
3470
3514
  F: __dxlog_file16,
3471
- L: 302,
3515
+ L: 326,
3472
3516
  S: this,
3473
3517
  C: (f, a) => f(...a)
3474
3518
  });
@@ -3480,18 +3524,23 @@ var EdgeReplicatorConnection = class extends Resource10 {
3480
3524
  this._onRestartRequested();
3481
3525
  return;
3482
3526
  }
3527
+ if (message.type === "sync") {
3528
+ this._inflightRequests--;
3529
+ if (this._inflightRequests === MAX_INFLIGHT_REQUESTS - 1) {
3530
+ this._outgoingRequestsBarrier.wake();
3531
+ }
3532
+ }
3483
3533
  this._readableStreamController.enqueue(message);
3484
3534
  }
3485
3535
  async _sendMessage(message) {
3486
3536
  message.targetId = this._targetServiceId;
3487
- log11("send", {
3537
+ log11.verbose("edge replicator send", {
3488
3538
  type: message.type,
3489
- senderId: message.senderId,
3490
- targetId: message.targetId,
3491
- documentId: message.documentId
3539
+ documentId: message.type === "sync" && message.documentId,
3540
+ remoteId: this._remotePeerId
3492
3541
  }, {
3493
3542
  F: __dxlog_file16,
3494
- L: 332,
3543
+ L: 360,
3495
3544
  S: this,
3496
3545
  C: (f, a) => f(...a)
3497
3546
  });