Instance Method
waitUntilBootstrapped(timeout:)
Block until Tor reports 100% bootstrap, or fail after timeout.
func waitUntilBootstrapped(timeout: Duration = .seconds(120)) async throws
Parameters
-
timeout
-
Maximum time to wait. Defaults to 2 minutes.
Mentioned In
Discussion
Polls the Tor control protocol once per second using getBootstrapStatus() and emits each observed phase as TorEvent.bootstrap(progress:tag:summary:) on events. Resolves successfully on the first reading with status.isComplete; throws TorError.timeout if the ContinuousClock deadline elapses first.
Uses ContinuousClock rather than Date so the timeout is immune to wall-clock jumps during bootstrap (DST transitions, manual clock changes). Bootstrap progress is monotonic, so subscribers may replace prior UI without reordering concerns.
Throws
TorError.notStarted when state is neither TorState.running nor TorState.starting; TorError.controlUnavailable when the control client has not bound; TorError.timeout when the deadline elapses.
Note
Cold-boot bootstraps typically complete in 30–60 seconds; warm-cache bootstraps (see cacheDirectory) in 5–10 seconds. Choose timeout with appropriate headroom.