Skip to content

Retry Temporal test / dev server startup - #198

Merged
philippzagar merged 1 commit into
apple:mainfrom
philippzagar:retry-ephemeral-server-start
Oct 13, 2026
Merged

philippzagar merged 1 commit into
apple:mainfrom
philippzagar:retry-ephemeral-server-start

Conversation

@philippzagar

@philippzagar philippzagar commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

TemporalTestServer starts the dev server (and the time-skipping test server) through Temporal Core. The first start on a machine downloads the Temporal CLI. Core then spawns the CLI and gives it a hardcoded 5 seconds to accept connections before killing it and failing (https://github.com/temporalio/sdk-rust/blob/9cb90f5a92c75167fe690a39c1ffd91f71a0fdfd/crates/sdk-core/src/ephemeral_server/mod.rs#L320). On a loaded host, for example CI running several suites that each start their own server, that window sometimes passes before the server is up:

BridgeError(message: "Connection failed: Failed connecting to test server after 5 seconds, last error: Some(TonicTransportError(tonic::transport::Error(Transport, ConnectError(ConnectError(\"tcp connect error\", 127.0.0.1:35923, Os { code: 111, kind: ConnectionRefused, message: \"Connection refused\" })))))", details: nil)

The timeout can't be configured from Swift, as it is hardcoded in the Core SDK, see the following code + TODO in the Rust Core:

// Try to connect every 100ms for 5s
// TODO(cretz): Some other way, e.g. via stdout, to know whether the server is up?
for _ in 0..50 {
    sleep(Duration::from_millis(100)).await;
    ...
}

The other SDKs built on Core (Python, TS, .NET, Ruby) have the same 5 s limit and don't retry. Go and Java start the server themselves and wait up to 60 s.

Modifications

  • Retry a failed server start up to 3 times, waiting 250ms between attempts. Core kills the process of a failed start, so each retry spawns a fresh server on a newly selected port. Only the start is retried, never the test body.

Result

Test suites no longer fail when a server misses Core's 5-second window. Starts that fail permanently, like a failed CLI download, now surface after the retries are used up rather than right away. This is a deliberate choice, as we don't want to parse and interpret the String-based error message that we get from Temporal Core. However, all of these permanent failures fail quickly and the retries are therefore retried quickly.

Test Plan

Existing server-dependent tests exercise the real start path.

@philippzagar philippzagar added the 🔨 semver/patch No public API change. label Oct 13, 2026

@FranzBusch FranzBusch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good but the CI isn't happy about this

@philippzagar

Copy link
Copy Markdown
Contributor Author

Generally looks good but the CI isn't happy about this

Seems like some dependency declaration stuff that only now surfaces (for whatever reason), let me fix that

@philippzagar

Copy link
Copy Markdown
Contributor Author

Generally looks good but the CI isn't happy about this

Seems like some dependency declaration stuff that only now surfaces (for whatever reason), let me fix that

This seems to be the issue, it's from upstream swift-distributed-tracing: apple/swift-distributed-tracing#240

This breaks our CI, especially as we build with warnings-as-errors. Will fix in another PR

@philippzagar

Copy link
Copy Markdown
Contributor Author

Fixed here: #199

@philippzagar
philippzagar force-pushed the retry-ephemeral-server-start branch from 83e0478 to 8566869 Compare October 13, 2026 09:43
@philippzagar
philippzagar enabled auto-merge (squash) October 13, 2026 09:44
@philippzagar
philippzagar merged commit 3a55853 into apple:main Oct 13, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants