-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(orchestration): prevent throwing on already defined workflow #5337
Conversation
🦋 Changeset detectedLatest commit: b4542f4 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Ignored Deployments
|
@carlos-r-l-rodrigues could you have a look at this pr please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we call WorkflowManager.unregisterAll()
right before exporting it?
I'm affraid that removing this validation, if new workflows are generated using the same name, it will be hard to debug what is causing it to not work as expected.
Or create another static property to flag if it's being imported twice and then we can just return.
Maybe instead we should get all workflows to register and then register them all allowing us to identify duplicated. The problem here is that if you have multiple medusajs/medusa package installed because you are working locally or because a package has a deps to it, then the same workflows are re registered. Because rhe import comes from the entry point and the way it is at the moment some import end up evaluating end point which import the workflow and try to re register it |
Is there a way we can detect if a workflow is an exact duplicate? |
I would say checking the flow step definition ? |
If we can, would it make sense to allow for "re-registration" of identical workflows and otherwise throw? |
I think it is reasonable, ill do that |
we can only check the definition, not the handlers. But I believe this is enough |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
@olivermrbl can I put an auto merge flag? |
Yep! |
What
At the moment, when importing something from medusa entry point, if two medusa packages are installed because of a plugin, the evaluation of the import can end up throwing that a workflow is already defined. To prevent that from happening, we can just not throw if it is already defined and just return prematurely and make it idempotent.