Dynamic Workflows with Mastra and Inngest

I might have found a bug regarding dynamic workflows with Mastra and Inngest. I use foreach to call a workflow step inside a workflow as described here.
When I try to run the workflow, it doesn't fail right away, but it doesn't finish the foreach step and I get two warnings:
⚠️  We detected that you have nested `step.*` tooling in `publish:workflow:dynamicWorkflowOrchestrator3:ade147cf-8ef5-4c6a-bbb2-d02812eb1082`
    at prettyError (file:///Users/smr/_dev/factro/mastra/node_modules/inngest/helpers/errors.js:231:51)
    at stepHandler (file:///Users/smr/_dev/factro/mastra/node_modules/inngest/components/execution/v1.js:751:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

It's possible to see this warning if steps are separated by regular asynchronous calls, which is fine. Nesting `step.*` tooling is not supported.

Make sure you're not using `step.*` tooling inside of other `step.*` tooling. If you need to compose steps together, you can create a new async function and call it from within your step function, or use promise chaining.

Code: NESTING_STEPS

=================================================
=================================================

⚠️  We detected that you have multiple steps with the same ID.

Your function is still running, though it may exhibit unexpected behaviour. This can happen if you're using the same ID for multiple steps across different chains of parallel work. We found the issue with step "publish:workflow:dynamicWorkflowOrchestrator3:ade147cf-8ef5-4c6a-bbb2-d02812eb1082". Using the same IDs across parallel chains of work can cause unexpected behaviour.

We recommend using a unique ID for each step, especially those happening in parallel.

Code: AUTOMATIC_PARALLEL_INDEXING
Control flow in Mastra workflows allows you to manage branching, merging, and conditions to construct workflows that meet your logic requirements.
Was this page helpful?