Skip to content

[Bug] Test environment sleep hangs on child workflows  #2392

Open
@ksapchuk

Description

@ksapchuk

What are you really trying to do?

We have a workflow that starts async child workflows with startChild that we want to test. The child workflows have delays in place and we want to sleep in the test environment to check intermediate workflow state.

Describe the bug

After starting the workflow with execute calling sleep on the time skipping TestWorkflowEnvironment seems to hang despite the child workflow having finished. The same test passes if starting the workflow with start.

Minimal Reproduction

Activities

export const createActivities = () => ({
  async runActivity(): Promise<void> {},
});

Workflows

const { runActivity } = proxyActivities<ReturnType<typeof createActivities>>({
  startToCloseTimeout: '5m',
});

export async function childWorkflow(): Promise<void> {
  await runActivity();
}

export async function parentWorkflow(): Promise<void> {
  await startChild(childWorkflow, { args: [], parentClosePolicy: ParentClosePolicy.PARENT_CLOSE_POLICY_ABANDON });
}

Test

  it('sleeps correctly', async () => {
    const mockActivities: ReturnType<typeof createActivities> = {
      async runActivity() {
        console.log('running activity');
      },
    };
    const worker = await Worker.create({
      connection: env.nativeConnection,
      taskQueue: 'test',
      workflowsPath: require.resolve('../workflows'),
      activities: mockActivities,
    });
    await worker.runUntil(async () => {
      await env.client.workflow.execute(parentWorkflow, {
        workflowId: uuid(),
        taskQueue: 'test',
        args: [],
      });
      await env.sleep('5 minutes');
    });
  });

Environment/Versions

  • OS and processor: M1 Mac,
  • Temporal Version: typescript sdk 1.7.2
  • Are you using Docker or Kubernetes or building Temporal from source?
    No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtest serverRelated to the test server

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions