Temporal SignalWithStart Behavior

Hi Team,

We are using Temporal java SDK version: 1.18.2 We have a workflow where we use signalWithStart and rely on some processing inside our signal method before starting our workflow. It is my understanding that the signal method should be executed and completed before the workflow method is started, however I notice that when I make an activity call inside the signal method it relinquishes control and the workflow method begins executing before the activity is completed inside the signal method. I am able to cross check this behavior inside the UI as well Here are the events

  1. WorkflowExecutionStarted
  2. WorkflowExecutionSignaled
  3. WorkflowTaskScheduled
  4. WorkflowTaskStarted
  5. WorkflowTaskCompleted
  6. ActivityTaskScheduled(This is the activity kicked off from my signal method)
  7. TimerStarted(This is a timer I have inside my workflow method however my signal method hasn’t completed so this shouldn’t happen)

I am trying to understand if this expected behavior?

The signal method is invoked before the main workflow method. As soon as it blocks the next thread is scheduled. This is by design.

If you really need to make sure that signal handler completes first, then you can use Workflow.await call in the main thread. This call can block until a variable is not updated at the end of the signal handler.