Skip to content

Allow replacing a worker's client when both use the default runtime - #1953

Open
wuchris-ch wants to merge 1 commit into
temporalio:mainfrom
wuchris-ch:fix/worker-client-default-runtime
Open

wuchris-ch wants to merge 1 commit into
temporalio:mainfrom
wuchris-ch:fix/worker-client-default-runtime

Conversation

@wuchris-ch

@wuchris-ch wuchris-ch commented Oct 10, 2026 •

Copy link
Copy Markdown

Fixes #657.

The bug: If you swap a worker's client (worker.client = new_client) and neither client was given a runtime, it fails with "New client is not on the same runtime as the existing client". But both clients are acutally on the same default runtime.

Why: A client with no runtime falls back to Runtime.default(). The check compared against the client's configured runtime, which is None, so it never matched.

The fix:

  • The service client now remembers the runtime it actually connected with.
  • The worker uses that when it's created and when its client is swapped.
  • The check doesn't create a default runtime just to compare. No recorded runtime means no match.
  • This is the second option suggested in [Bug] Cannot replace worker client if default Runtime is used #657, so the client's config stays as the user set it.

Still rejected (the case from the #1707 review): a worker on a custom runtime plus a new client with no runtime. That client is on the default runtime, so it's a real mismatch.

Tests:

  • test_workflow_replace_worker_client_implicit_default_runtime: fails on main with the error above, passes with this change.
  • test_workflow_replace_worker_client_implicit_default_runtime_mismatch_fail: the custom runtime case.
  • Ran locally: poe build-develop, poe lint and poe test (1446 passed, 9 skipped). The new tests also pass with --workflow-environment time-skipping.
  • Changelog: changelog/fixed/relay-racing-raccoon.md (changelog-tool check passes).

@wuchris-ch
wuchris-ch requested a review from a team as a code owner October 10, 2026 03:56
@CLAassistant

CLAassistant commented Oct 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@wuchris-ch
wuchris-ch force-pushed the fix/worker-client-default-runtime branch from 3409509 to e1900cd Compare October 10, 2026 04:20

This branch has not been deployed

No deployments
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.

[Bug] Cannot replace worker client if default Runtime is used

2 participants