WorkflowRunNotCompletedError

WorkflowRunNotCompletedError is thrown when requesting the result of a workflow run that has not completed yet. The run's current status (for example pending or running) is available on the error.

run.returnValue() handles this error internally (it polls until the run completes), so you will mainly encounter it when building custom polling logic on lower-level APIs.

import { WorkflowRunNotCompletedError } from "workflow/errors"
declare function readRunResult(runId: string): Promise<unknown>; // @setup
declare const runId: string; // @setup

try {
  const result = await readRunResult(runId);
} catch (error) {
  if (WorkflowRunNotCompletedError.is(error)) {
    console.log(`Run ${error.runId} is still ${error.status}`);
  }
}

API signature

Properties

NameTypeDescription
runIdstringThe workflow run ID.
statusstringThe run's status at the time of the error (e.g. "pending", "running").
messagestringThe error message.

Static methods

WorkflowRunNotCompletedError.is(value)

Type-safe check for WorkflowRunNotCompletedError instances. Preferred over instanceof because it works across module boundaries and virtual machine contexts.

import { WorkflowRunNotCompletedError } from "workflow/errors"
declare const error: unknown; // @setup

if (WorkflowRunNotCompletedError.is(error)) {
  // error is typed as WorkflowRunNotCompletedError
}