Skip to content

fix: allow replacing worker client on default runtime - #1707

Open
Sakshamm-Goyal wants to merge 2 commits into
temporalio:mainfrom
Sakshamm-Goyal:agent/fix-worker-lazy-runtime-client
Open

fix: allow replacing worker client on default runtime#1707
Sakshamm-Goyal wants to merge 2 commits into
temporalio:mainfrom
Sakshamm-Goyal:agent/fix-worker-lazy-runtime-client

Conversation

@Sakshamm-Goyal

Copy link
Copy Markdown
Contributor

Fixes #657.

A replacement client with no explicit runtime uses Runtime.default(), but the worker compared the configured runtime value directly and treated None as a different runtime. Resolve the replacement client runtime with the same defaulting rule used during worker construction before comparing identities.

Regression coverage connects a second client without supplying runtime and verifies it can replace a worker client. The explicit different-runtime rejection remains covered.

Validated with:

  • pytest tests/worker/test_workflow.py::test_workflow_replace_worker_client_default_runtime tests/worker/test_workflow.py::test_workflow_replace_worker_client_diff_runtimes_fail -q
  • ruff format --check temporalio/worker/_worker.py tests/worker/test_workflow.py
  • git diff --check

@Sakshamm-Goyal
Sakshamm-Goyal requested a review from a team as a code owner July 31, 2026 03:44
Comment thread temporalio/worker/_worker.py Outdated
@Sakshamm-Goyal

Copy link
Copy Markdown
Contributor Author

Addressed the runtime-selection concern in 8c313d8. The setter now compares only an explicitly configured runtime; it no longer creates Runtime.default() merely to validate a replacement client with no configured runtime. Explicit mismatches still raise.

The regression now creates the worker with a non-default runtime and replaces its client with one that has no runtime argument, which failed under the previous check. Source compilation and focused Mypy passed. I attempted the targeted pytest path, but this worktree's SDK Core submodule is absent, so its bridge extension cannot be built locally; fresh CI is queued for the full pinned-environment test.

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