fix(worker): dedupe discovered workflows by defining module#20
Draft
HHK1 wants to merge 1 commit into
Draft
Conversation
Workflow classes imported from a sibling module (e.g. a parent workflow importing a child to call via execute_workflow) were picked up by inspect.getmembers in every module that re-exported them, registering the same class twice and tripping Temporal's 'More than one workflow named X' check at worker startup. Filter by obj.__module__ == modname so only classes defined in the scanned module count, and track seen classes as a safety net. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
discover_workflows()usesinspect.getmembers(module, inspect.isclass)which returns every class accessible in the module's namespace — including classes imported from sibling modules.When one workflow imports another to call it via
execute_workflow(a common parent/child pattern), the child workflow class is picked up by the scanner in both the module that defines it and the module that imports it. Both registrations are passed torun_worker, and Temporal rejects the duplicate at worker startup:Repro
Worker startup fails because
ChildWorkflowis discovered twice.Fix
obj.__module__ == modnameso only classes defined in the scanned module count.seenset as a belt-and-braces guard against any other duplicate paths.Test
Manually verified on a project that hit the original error — worker now starts cleanly with two workflows where one imports the other.
Generated by Mistral Vibe.