Rerun temporal cron job

Hi team.

We are facing a problem in that we can’t rerun our cron job workflows with new changes.

2022-12-07T13:25:26.945Z [worker] info: Workflow execution already started
2022-12-07T13:25:26.957Z [worker] info: Workflow execution already started
2022-12-07T13:25:26.971Z [worker] info: Workflow execution already started

Every time when we deploy our changes to temporal we run the start script. Where we are running our worker and then start the cron job workflows.

  const handle = await client.start('workflowName', {
    args: [currencyCode],
    taskQueue: 'TaskQueue',
    workflowId: workflowIdPrefix + currencyCode,
    cronSchedule: `${minute} * * * *`,
  });

  workerLogger.info(`workflow ${handle.workflowId} started`);

We try to cancel running workflows and run them one more time. But facing the same issue. Temporal cancel existing workflows and can’t run a new one. Do we have any idea how to rerun the temporal cron job?

async function terminateWorkflow(currencyCode: CurrencyCode) {
  const client = await getWorkflowClient();
  const handle = client.getHandle(workflowIdPrefix + currencyCode);

  try {
    await handle.cancel();

    workerLogger.info(`workflow ${handle.workflowId} terminated`);
  } catch {
    workerLogger.info(
      `workflow ${handle.workflowId} execution already completed`
    );
  }
}

await handle.cancel();

With cron, think this should be

await handle.terminate(reason);

To stop a current cron execution you have to either terminate it, or set workflow execution timeout in worker options that would stop it when this timer is triggered.