<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Tor",
  "identifier" : "/documentation/Tor/TorClient/waitUntilBootstrapped(timeout:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Tor"
    ],
    "preciseIdentifier" : "s:3Tor0A6ClientC21waitUntilBootstrapped7timeoutys8DurationV_tYaKF"
  },
  "title" : "waitUntilBootstrapped(timeout:)"
}
-->

# 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.

## Discussion

Polls the Tor control protocol once per second using
[`getBootstrapStatus()`](/documentation/Tor/TorControlClient/getBootstrapStatus()) and emits each observed
phase as [`TorEvent.bootstrap(progress:tag:summary:)`](/documentation/Tor/TorEvent/bootstrap(progress:tag:summary:)) on
[`events`](/documentation/Tor/TorClient/events). Resolves successfully on the first reading with
`status.isComplete`; throws [`TorError.timeout`](/documentation/Tor/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: ``doc://Tor/documentation/Tor/TorError/notStarted`` when ``doc://Tor/documentation/Tor/TorClient/state`` is neither
> ``doc://Tor/documentation/Tor/TorState/running`` nor ``doc://Tor/documentation/Tor/TorState/starting``;
> ``doc://Tor/documentation/Tor/TorError/controlUnavailable`` when the control client has
> not bound; ``doc://Tor/documentation/Tor/TorError/timeout`` when the deadline elapses.

> Note: Cold-boot bootstraps typically complete in 30–60 seconds;
> warm-cache bootstraps (see ``doc://Tor/documentation/Tor/TorConfiguration/cacheDirectory``)
> in 5–10 seconds. Choose `timeout` with appropriate headroom.