Skip to content

Cancellation and timeouts

Every typed API method accepts a CancellationToken.

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));
var project = await client.Projects.GetAsync(projectId, cancellationToken: cts.Token);

The SDK also has its own request timeout. A per-call timeout overrides the client default:

await client.Projects.GetAnalyticsAsync(projectId,
    new OkatanaRequestOptions { Timeout = TimeSpan.FromSeconds(8) },
    cancellationToken);

Caller cancellation is preserved as cancellation. An SDK timeout that expires while the caller token is still active is treated as a transport timeout and may participate in the safe-read retry policy.

When injecting a custom HttpClient, avoid setting HttpClient.Timeout to a value shorter than the SDK timeout unless you intentionally want the outer HttpClient timeout to win. The standalone SDK client disables the built-in HttpClient.Timeout and uses the SDK cancellation mechanism.