I am seeing an issue where there is a race condition between any activities started in a signal handler and the completion of the workflow. If I trigger a signal before the end of the workflow, the signal is received and the activity runs, but failure retries will stop if the workflow completes.
Here is some example code
import {
defineSignal,
setHandler,
sleep,
proxyActivities,
} from "@temporalio/workflow";
import type * as activities from "@api/_temporal/shared-activities";
const { failingActivityWithDelay } = proxyActivities<typeof activities>({
startToCloseTimeout: "1 minute",
retry: {
maximumAttempts: 10,
},
});
export const testFailSignal = defineSignal("testFailSignal");
export async function testWorkflow() {
setHandler(testFailSignal, async () => {
await failingActivityWithDelay(); // Fails after 5 seconds
});
await sleep(20 * 1000);
}
In the above code it will retry 4 times (4 * 5 seconds), but any retries after the sleep completes don’t happen. In addition the workflow is marked as completed (not failed).