Skip to content

Add connect_timeout option to ConnectionOptions#1422

Open
nlively wants to merge 2 commits into
temporalio:mainfrom
nlively:nlively/connect-timeout
Open

Add connect_timeout option to ConnectionOptions#1422
nlively wants to merge 2 commits into
temporalio:mainfrom
nlively:nlively/connect-timeout

Conversation

@nlively

@nlively nlively commented Jul 24, 2026

Copy link
Copy Markdown

Adds a connect_timeout: Option<Duration> field to ConnectionOptions that bounds how long TCP/TLS connection establishment can take. Without this, connection attempts to unreachable hosts block indefinitely (or until OS-level TCP timeouts kick in, typically 30–120s), which makes it difficult for callers to implement responsive failure handling.

Changes

  • Added connect_timeout field to ConnectionOptions with documentation
  • Applied the timeout in Connection::connect_once() for direct (non-DNS) connections
  • Threaded through dns::build_endpoint() and dns::spawn_dns_reresolution() so DNS-balanced connections also respect the timeout on initial connect and during background re-resolution
  • Added a test that verifies a 500ms timeout properly bounds a connection attempt to a non-routable IP

Usage

let opts = ConnectionOptions::new(url)
    .connect_timeout(Duration::from_millis(5_000))
    .build();
let conn = Connection::connect(opts).await?;

When connect_timeout is None (the default), behavior is unchanged — no explicit timeout is applied.

@nlively
nlively requested a review from a team as a code owner July 24, 2026 15:58
@Sushisource
Sushisource enabled auto-merge (squash) July 24, 2026 17:47
@CLAassistant

CLAassistant commented Jul 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

auto-merge was automatically disabled July 24, 2026 20:47

Head branch was pushed to by a user without write access

@nlively
nlively force-pushed the nlively/connect-timeout branch from 6bd913c to f955e13 Compare July 24, 2026 22:12
@Sushisource
Sushisource enabled auto-merge (squash) July 24, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants