Parent Workflow - Wait for all child workflows to complete

In the below workflow, I am trying to do some work, call 3 child workflows, once they’re completed, do some more work. But the parent workflow is not waiting for the child workflows to complete. Instead initiates it, and continues to do the rest of the work. await Promise.all(childWorkflows) is not expected to wait for the child workflows to be completed ?

const refreshData = async ({ pk, action }) => {
  const { provider } = await getProvider({ pk })
  // Fetch projects
  const projects = await fetchProjects({ pk })

  // Start child workflows in parallel
  const childWorkflows = [
    startChild(refreshClustersWorkflow, {
      args: [{ provider, action, projects }],
    }),
    startChild(refreshServerLessInstancesWorkflow, {
      args: [{ provider, action, projects }],
    }),
    startChild(refreshUsersWorkflow, {
      args: [{ pk, action }],
    }),
  ]
  // Wait for all child workflows to complete
  const results = await Promise.all(childWorkflows)
  await refreshEntities({ action, pk })
}

How can this be achieved if not this way?

Believe since you use startChild you are only waiting for the child workflows to start, not complete. should probably use executeChild instead.

1 Like

That worked, thanks!