How to find if a workflow is running or not using TypeScript.
Use the @temporalio/client
API to make a client connection to Temporal, then make a handle for that workflow, and finally, describe()
it. The current status of the workflow is in workflowDescription.status
.
try {
const workflowDescription = await client.getHandle('workflow-id').describe();
const isRunning = workflowDescription.status.name === 'RUNNING';
} catch (e: unknown) {
if (e instanceof WorkflowNotFound) {
// The workflow does not even exists
}
}
1 Like