temporalio / temporalio/sdk-java

[Bug] Test environment sleep hangs on child workflows

Open
#2,392 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug test server
Dominant language
Java
Stars
433
Forks
249
Avg merge
5d 6h
Merged PRs (30d)
26

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproduction using TestWorkflowEnvironment, Worker.runUntil, workflow.execute, and env.sleep; compare it with the passing workflow.start case. Trace how TestWorkflowEnvironment handles time skipping after startChild and verify that sleeping returns after the child workflow finishes. Done means the reproduced test completes without hanging.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.