Open
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