@peerbit/shared-log 16.0.29 → 16.0.31

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.
@@ -879,7 +879,9 @@ export class SimpleSyncronizer<R extends "u32" | "u64">
879
879
  const epoch =
880
880
  expectedEpoch ??
881
881
  currentEpoch ??
882
- (options?.createTargetEpochs === false
882
+ (options?.createTargetEpochs === false ||
883
+ this.closed === true ||
884
+ ownershipLifecycleController.signal.aborted
883
885
  ? undefined
884
886
  : this.getOrCreateSyncDispatchTargetEpoch(target));
885
887
  if (!epoch) {
@@ -2362,7 +2364,11 @@ export class SimpleSyncronizer<R extends "u32" | "u64">
2362
2364
  requestedCount: trackedHashes.length,
2363
2365
  requestedTotalCount: allHashes.length,
2364
2366
  attempts: 0,
2365
- targetEpoch: this.getOrCreateSyncDispatchTargetEpoch(target),
2367
+ // Rejected late repairs only need result metadata. Do not create a
2368
+ // retained dispatch epoch after the terminal admission fence.
2369
+ targetEpoch: this.closed
2370
+ ? { id: 0 }
2371
+ : this.getOrCreateSyncDispatchTargetEpoch(target),
2366
2372
  });
2367
2373
  }
2368
2374
 
@@ -2377,6 +2383,10 @@ export class SimpleSyncronizer<R extends "u32" | "u64">
2377
2383
  deferred,
2378
2384
  cancelled: false,
2379
2385
  };
2386
+ if (this.closed) {
2387
+ deferred.resolve(this.buildRepairSessionResult(session, false));
2388
+ return { id, done: deferred.promise, cancel: () => {} };
2389
+ }
2380
2390
 
2381
2391
  if (allHashes.length === 0 || targets.length === 0) {
2382
2392
  deferred.resolve(this.buildRepairSessionResult(session, true));
@@ -3755,9 +3765,13 @@ export class SimpleSyncronizer<R extends "u32" | "u64">
3755
3765
  });
3756
3766
  }
3757
3767
 
3758
- async close() {
3768
+ beginClose(): void {
3759
3769
  this.closed = true;
3760
3770
  this.syncDispatchLifecycleController.abort();
3771
+ }
3772
+
3773
+ async close() {
3774
+ this.beginClose();
3761
3775
  this.syncDispatchTargetEpochs.clear();
3762
3776
  this.clearPendingSyncAdmissions();
3763
3777
  this.syncInFlightRetryIterator = undefined;