ServiceError: Failed to start Workflow

Using TypeScript, an error occurs when calling Temporal execute for scheduled tasks.

    async startCronWorkflow(id: string, queue: string, workflow: string,  args: Array<any>, duration: string):Promise<Boolean> {
        console.log(id, queue, workflow, args, duration)
        const handle = await this.client.workflow.execute(workflow, {
            taskQueue: queue, args: args, workflowId: id, cronSchedule: `every ${duration}`});
        return true;
    }

error message

ServiceError: Failed to start Workflow
    at WorkflowClient.rethrowGrpcError (xxx/node_modules/@temporalio/client/src/workflow-client.ts:592:13)
    at WorkflowClient._startWorkflowHandler (xxx/node_modules/@temporalio/client/src/workflow-client.ts:742:12)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at WorkflowClient.execute (xxx/node_modules/@temporalio/client/src/workflow-client.ts:456:5)
    at TemporalService.startCronWorkflow (xxx/src/temporal/temporal.service.ts:34:24)
    at CronjobService.start (xxx/src/cronjob/cronjob.service.ts:16:21)

Use docker-compose to install Temporal on a Mac M2 computer.

Are you able to run the samples? Can you connect to the cluster using CLI?

Yes, the “Hello World” program has been successfully run.

➜  hello-world npm run workflow

> temporal-hello-world@0.1.0 workflow
> ts-node src/client.ts

Started workflow workflow-2LDabOySZas_5UkAu6uXK
Hello, Temporal!

Have you compared how “Hello World” client initialization differs from your program?

We’re using typescript-sdk with our self-hosted temporal cluster. We recently started getting these failures while starting workflow execution. But we’re not seeing any errors in temporal logs. Any help with how we can fix these?

These happen rarely but seem intermittent.

{
  "stack": "ServiceError: Failed to start Workflow\n    at WorkflowClient.rethrowGrpcError (/app/node_modules/@temporalio/client/lib/workflow-client.js:245:19)\n    at WorkflowClient._startWorkflowHandler (/app/node_modules/@temporalio/client/lib/workflow-client.js:391:18)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async WorkflowClient.execute (/app/node_modules/@temporalio/client/lib/workflow-client.js:147:9)",
  "level": "error",
  "name": "ServiceError",
  "cause": {
    "metadata": {
      "date": ["Sat, 29 Jul 2023 05:25:00 GMT"],
      "l5d-proxy-connection": ["close"],
      "content-length": ["0"],
      "l5d-proxy-error": ["unexpected error"],
      "content-type": ["application/grpc"]
    },
    "code": 13,
    "details": "unexpected error"
  },
  "timestamp": "2023-07-29 05:25:00"
}

We couldn’t find any pattern for these and it seems like retrying again works.