-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[Bug]: Handling dynamically sized input data in workflows #10194
Comments
A bit off-topic: |
Sorry, this behavior is caused by another bug in a workflows engine |
Your hook function should be like a createStep definition, the example above using Regarding multiple executions, currently we don't yet support a "loop" in the workflow composition. basically you wrap a try/catch in you createProduct workflow, storing the necessary data to revert it, and if there is failure you can revert it on the compensation step. You can see how it is used in this test: |
Nah, that’s not a very elegant solution because I essentially have to re-implement the Something like this
would be much better, IMHO |
A proper loop functionality that you can run multiple batches inside the same step will come in the future. I'm not sure why you would need to reimplement what you mentioned, in theory you either call another workflow to delete what you created or you could call the workflow method to cancel the transaction, which essentially is the same as reverting all steps after the workflow is done. However this isn't yet documented. |
Package.json file
Node.js version
v20
Database and its version
16.2
Operating system name and version
Mac OS X
Browser name
No response
What happended?
As I understand it, there’s no way to process dynamically sized input data in workflows because we need a
for-each
mechanism for steps.Let me clarify with an example:
This approach is not feasible.
I have a workflow that takes a single product as input. It creates an entity in my CMS and updates a MedusaJS product’s metadata using the
updateProductsStep
from the core workflows. I want to use this workflow as a step within the product creation workflow hook. However, it’s currently not possible to process an array of products in this way.Even if my workflow receives an array of products to create in the CMS, I can’t invoke updateProductsStep multiple times within the workflow — there’s simply no mechanism for that
Such an approach won’t work either because there would be no compensation if it fails on the third product.
Expected behavior
We need a mechanism to invoke steps either in parallel or sequentially within a workflow, based on dynamically sized input.
Actual behavior
There is no such mechanism
Link to reproduction repo
no need
The text was updated successfully, but these errors were encountered: