Skip to content

Commit 9565e8f

Browse files
authored
test(workflow): Add test of workflow cancellation while update handler is executing (#1482)
1 parent 095912f commit 9565e8f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/test/src/test-integration-update.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,28 @@ test('update result poll throws WorkflowUpdateRPCTimeoutOrCancelledError', async
602602
});
603603
});
604604

605+
const updateThatShouldFail = wf.defineUpdate('updateThatShouldFail');
606+
607+
export async function workflowThatWillBeCanceled(): Promise<void> {
608+
wf.setHandler(updateThatShouldFail, async () => {
609+
await wf.condition(() => false);
610+
});
611+
await wf.condition(() => false);
612+
}
613+
614+
test('update caller gets update failed error on workflow cancellation', async (t) => {
615+
const { createWorker, startWorkflow, assertWorkflowUpdateFailed } = helpers(t);
616+
const worker = await createWorker();
617+
await worker.runUntil(async () => {
618+
const w = await startWorkflow(workflowThatWillBeCanceled);
619+
const u = await w.startUpdate(updateThatShouldFail, {
620+
waitForStage: WorkflowUpdateStage.ACCEPTED,
621+
});
622+
await w.cancel();
623+
await assertWorkflowUpdateFailed(u.result(), wf.CancelledFailure, 'Workflow cancelled');
624+
});
625+
});
626+
605627
export { signalUpdateOrderingWorkflow };
606628

607629
// Validate that issue #1474 is fixed in 1.11.0+

0 commit comments

Comments
 (0)