Asynchronous child workflow execution problem

Hello!
I’ve got a problem with child workflow working.

The child workflow is initialized, but the execution does not start

I assume that the problem is due to the fact that it does not have time to start execution - the parent workflow finishes faster.

I found a bestway for java - Best way to create an async child workflow that looks like the one I need

Point 4 says “Wait for the Promise returned by getWorkflowExecution to complete. ”

Can you please tell me how this can be implemented using php-sdk?

My code now looks like this (called inside the parent workflow)

Workflow::asyncDetached(
            task: static function (): void {
                $options = ChildWorkflowOptions::new()
                    ->withTaskQueue('task_name')
                    ->withParentClosePolicy(ParentClosePolicy::Abandon);

                $workflow = Workflow::newChildWorkflowStub(
                    class: MyChildWorkflowInterface::class,
                    options: $options,
                );

                $workflow->execute(); // workflow logic
            },
        );

You must at least wait for the workflow to start, otherwise it won’t be scheduled.

Check untyped workflow stub, it exposes method to start workflow and receive execution id without blocking on result.

1 Like