... |
... |
@@ -278,10 +278,13 @@ class BootstrapAttempt { |
278
|
278
|
lazy.logger.warn("Cancelled bootstrap after it has already resolved");
|
279
|
279
|
return;
|
280
|
280
|
}
|
281
|
|
- // Wait until after bootstrap.cancel returns before we resolve with
|
282
|
|
- // cancelled. In particular, there is a small chance that the bootstrap
|
283
|
|
- // completes, in which case we want to be able to resolve with a success
|
284
|
|
- // instead.
|
|
281
|
+ // Wait until after #bootstrap.cancel returns before we resolve with
|
|
282
|
+ // cancelled. In particular:
|
|
283
|
+ // + there is a small chance that the bootstrap completes, in which case we
|
|
284
|
+ // want to be able to resolve with a success instead.
|
|
285
|
+ // + we want to make sure that we only resolve this BootstrapAttempt
|
|
286
|
+ // when the current TorBootstrapRequest instance is fully resolved so
|
|
287
|
+ // there are never two competing instances.
|
285
|
288
|
await this.#bootstrap?.cancel();
|
286
|
289
|
this.#resolveRun({ result: "cancelled" });
|
287
|
290
|
}
|
... |
... |
@@ -636,13 +639,15 @@ class AutoBootstrapAttempt { |
636
|
639
|
return;
|
637
|
640
|
}
|
638
|
641
|
|
639
|
|
- // Wait until after bootstrap.cancel returns before we resolve with
|
640
|
|
- // cancelled. In particular, there is a small chance that the bootstrap
|
641
|
|
- // completes, in which case we want to be able to resolve with a success
|
642
|
|
- // instead.
|
|
642
|
+ // Wait until after #bootstrapAttempt.cancel returns before we resolve with
|
|
643
|
+ // cancelled. In particular:
|
|
644
|
+ // + there is a small chance that the bootstrap completes, in which case we
|
|
645
|
+ // want to be able to resolve with a success instead.
|
|
646
|
+ // + we want to make sure that we only resolve this AutoBootstrapAttempt
|
|
647
|
+ // when the current TorBootstrapRequest instance is fully resolved so
|
|
648
|
+ // there are never two competing instances.
|
643
|
649
|
if (this.#bootstrapAttempt) {
|
644
|
|
- this.#bootstrapAttempt.cancel();
|
645
|
|
- await this.#bootstrapAttempt;
|
|
650
|
+ await this.#bootstrapAttempt.cancel();
|
646
|
651
|
}
|
647
|
652
|
// In case no bootstrap is running, we resolve with "cancelled".
|
648
|
653
|
this.#resolveRun({ result: "cancelled" });
|