WorkflowRunCancelledError

Thrown when awaiting the return value of a canceled workflow run.

WorkflowRunCancelledError is thrown when awaiting run.returnValue on a workflow run that was explicitly canceled via run.cancel(). Canceled runs do not produce a return value.

You can check for cancellation before awaiting by inspecting run.status.

import { WorkflowRunCancelledError } from "workflow/errors"
declare const run: { status: Promise<string>; returnValue: Promise<any> }; // @setup

try {
  const result = await run.returnValue;
} catch (error) {
  if (WorkflowRunCancelledError.is(error)) {
    console.log(`Run ${error.runId} was cancelled`);
  }
}

API signature

Properties

NameTypeDescription
runIdstringThe ID of the canceled run.
messagestringThe error message.

Static methods

WorkflowRunCancelledError.is(value)

Type-safe check for WorkflowRunCancelledError instances. Preferred over instanceof because it works across module boundaries and VM contexts.

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

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