Skip to content

@temporal-contract/worker


@temporal-contract/worker / workflow

workflow ​

Classes ​

ActivityCancelledError ​

Defined in: packages/worker/src/errors.ts:371

Discriminated variant surfaced when a call to an activity was cancelled (the workflow itself, or an enclosing cancellation scope) — every activity call rides this branch now, not only ones that declare an errors map. Detected via @temporalio/workflow's isCancellation(...).

A sibling of ActivityError rather than a subclass, for the same reason ChildWorkflowCancelledError is a sibling of ChildWorkflowError: call sites discriminate on the _tag.

Swallowing this error changes the workflow outcome. Cancellation rides the modeled Err(...) channel here, so generic error handling (e.g. mapping every Err to a "failed" result and returning normally) makes the workflow complete as Completed instead of Cancelled. When the workflow should honor the cancellation request, re-raise it with rethrowCancellation.

Unlike ActivityError, cause here is already the value exactly as caught (classifyActivityError checks cancellation before unwrapping ActivityFailure) — so there is no separate originalFailure to retain; propagateFailure re-raises cause directly.

Extends ​

  • TaggedErrorInstance<"@temporal-contract/ActivityCancelledError", { activityName: string; cause?: unknown; }>

Constructors ​

Constructor ​
ts
new ActivityCancelledError(activityName, cause?): ActivityCancelledError;

Defined in: packages/worker/src/errors.ts:377

Parameters ​
ParameterType
activityNamestring
cause?unknown
Returns ​

ActivityCancelledError

Overrides ​
ts
TaggedError(ACTIVITY_CANCELLED_ERROR_TAG, {
  name: "ActivityCancelledError",
})<{
  activityName: string;
  cause?: unknown;
}>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"@temporal-contract/ActivityCancelledError"TaggedError(ACTIVITY_CANCELLED_ERROR_TAG, { name: "ActivityCancelledError", })._tagnode_modules/.pnpm/unthrown@5.7.0/node_modules/unthrown/dist/index.d.mts:2011
activityNamereadonlystringTaggedError(ACTIVITY_CANCELLED_ERROR_TAG, { name: "ActivityCancelledError", }).activityNamepackages/worker/src/errors.ts:374
cause?publicunknownActivityDefinitionNotFoundError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError(ACTIVITY_CANCELLED_ERROR_TAG, { name: "ActivityCancelledError", }).messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError(ACTIVITY_CANCELLED_ERROR_TAG, { name: "ActivityCancelledError", }).namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError(ACTIVITY_CANCELLED_ERROR_TAG, { name: "ActivityCancelledError", }).stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

ActivityError ​

Defined in: packages/worker/src/errors.ts:336

Generic error surfaced on the Err(...) branch when an activity that declares contract errors fails for a reason other than one of its declared errors — retries exhausted on a technical failure, a timeout, an undeclared ApplicationFailure type, or a validation failure at the workflow → activity boundary.

Mirrors ChildWorkflowError: cause is the unwrapped actionable failure (Temporal's ActivityFailure wrapper is seen through), so callers can branch on the failure category in one step.

Every activity call surfaces this — the workflow-side call convention no longer depends on whether the contract declares an errors map; only the error channel's declared-error members do.

originalFailure is a second, separate retention: the value exactly as it was caught, before classifyActivityError unwrapped it into cause (typically Temporal's ActivityFailure wrapper). cause's unwrapping is documented, caller-facing behavior and stays as-is — originalFailure exists purely so propagateFailure can re-raise the exact failure Temporal originally produced, without changing what cause means. Unset when there is no separate wrapper to retain (e.g. the input/output validation branches, where cause is already the terminal failure).

Extends ​

  • TaggedErrorInstance<"@temporal-contract/ActivityError", { activityName: string; cause?: unknown; originalFailure?: unknown; }>

Constructors ​

Constructor ​
ts
new ActivityError(
   activityName, 
   message, 
   cause?, 
   originalFailure?
): ActivityError;

Defined in: packages/worker/src/errors.ts:343

Parameters ​
ParameterType
activityNamestring
messagestring
cause?unknown
originalFailure?unknown
Returns ​

ActivityError

Overrides ​
ts
TaggedError(ACTIVITY_ERROR_TAG, {
  name: "ActivityError",
})<{
  activityName: string;
  cause?: unknown;
  originalFailure?: unknown;
}>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"@temporal-contract/ActivityError"TaggedError(ACTIVITY_ERROR_TAG, { name: "ActivityError", })._tagnode_modules/.pnpm/unthrown@5.7.0/node_modules/unthrown/dist/index.d.mts:2011
activityNamereadonlystringTaggedError(ACTIVITY_ERROR_TAG, { name: "ActivityError", }).activityNamepackages/worker/src/errors.ts:339
cause?publicunknownActivityDefinitionNotFoundError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError(ACTIVITY_ERROR_TAG, { name: "ActivityError", }).messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError(ACTIVITY_ERROR_TAG, { name: "ActivityError", }).namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
originalFailure?readonlyunknownTaggedError(ACTIVITY_ERROR_TAG, { name: "ActivityError", }).originalFailurepackages/worker/src/errors.ts:341
stack?publicstringTaggedError(ACTIVITY_ERROR_TAG, { name: "ActivityError", }).stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

ChildWorkflowCancelledError ​

Defined in: packages/worker/src/errors.ts:446

Discriminated variant surfaced when a child workflow operation (start, execute, or wait-for-result) was cancelled — either because the parent workflow itself was cancelled, the child was explicitly cancelled, or its enclosing cancellation scope was. Detected via @temporalio/workflow's isCancellation(...), which sees through nested ChildWorkflowFailure / CancelledFailure chains.

A sibling of ChildWorkflowError rather than a subclass: both are distinct TaggedErrors, so call sites discriminate on the _tag (or instanceof ChildWorkflowCancelledError) instead of relying on an instanceof ChildWorkflowError that also matches cancellation. A result.match with the exhaustive errCases matcher folds the ChildWorkflowError | ChildWorkflowCancelledError union exhaustively.

Swallowing this error changes the workflow outcome. Cancellation rides the modeled Err(...) channel here, so generic error handling (e.g. mapping every Err to a "failed" result and returning normally) makes the parent workflow complete as Completed instead of Cancelled. When the workflow should honor the cancellation request, re-raise it with rethrowCancellation.

Extends ​

  • TaggedErrorInstance<"@temporal-contract/ChildWorkflowCancelledError", { cause?: unknown; workflowName: string; }>

Constructors ​

Constructor ​
ts
new ChildWorkflowCancelledError(workflowName, cause?): ChildWorkflowCancelledError;

Defined in: packages/worker/src/errors.ts:452

Parameters ​
ParameterType
workflowNamestring
cause?unknown
Returns ​

ChildWorkflowCancelledError

Overrides ​
ts
TaggedError(CHILD_WORKFLOW_CANCELLED_ERROR_TAG, {
  name: "ChildWorkflowCancelledError",
})<{
  workflowName: string;
  cause?: unknown;
}>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"@temporal-contract/ChildWorkflowCancelledError"TaggedError(CHILD_WORKFLOW_CANCELLED_ERROR_TAG, { name: "ChildWorkflowCancelledError", })._tagnode_modules/.pnpm/unthrown@5.7.0/node_modules/unthrown/dist/index.d.mts:2011
cause?publicunknownActivityDefinitionNotFoundError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError(CHILD_WORKFLOW_CANCELLED_ERROR_TAG, { name: "ChildWorkflowCancelledError", }).messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError(CHILD_WORKFLOW_CANCELLED_ERROR_TAG, { name: "ChildWorkflowCancelledError", }).namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError(CHILD_WORKFLOW_CANCELLED_ERROR_TAG, { name: "ChildWorkflowCancelledError", }).stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
workflowNamereadonlystringTaggedError(CHILD_WORKFLOW_CANCELLED_ERROR_TAG, { name: "ChildWorkflowCancelledError", }).workflowNamepackages/worker/src/errors.ts:449

ChildWorkflowError ​

Defined in: packages/worker/src/errors.ts:412

Generic error for child workflow operations.

When the child execution itself fails (Temporal's ChildWorkflowFailure), cause is set to the unwrapped underlying failure (ApplicationFailure, TimeoutFailure, TerminatedFailure, etc.) lifted from Temporal's wrapper — mirroring the client-side WorkflowFailedError.cause behavior, so callers can branch on the failure category in one step instead of unwrapping twice.

Carries the child's workflowName as a structured field (matching its sibling ChildWorkflowCancelledError) so callers don't have to parse it out of message.

Extends ​

  • TaggedErrorInstance<"@temporal-contract/ChildWorkflowError", { cause?: unknown; workflowName: string; }>

Constructors ​

Constructor ​
ts
new ChildWorkflowError(
   workflowName, 
   message, 
   cause?
): ChildWorkflowError;

Defined in: packages/worker/src/errors.ts:418

Parameters ​
ParameterType
workflowNamestring
messagestring
cause?unknown
Returns ​

ChildWorkflowError

Overrides ​
ts
TaggedError(CHILD_WORKFLOW_ERROR_TAG, {
  name: "ChildWorkflowError",
})<{
  workflowName: string;
  cause?: unknown;
}>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"@temporal-contract/ChildWorkflowError"TaggedError(CHILD_WORKFLOW_ERROR_TAG, { name: "ChildWorkflowError", })._tagnode_modules/.pnpm/unthrown@5.7.0/node_modules/unthrown/dist/index.d.mts:2011
cause?publicunknownActivityDefinitionNotFoundError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError(CHILD_WORKFLOW_ERROR_TAG, { name: "ChildWorkflowError", }).messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError(CHILD_WORKFLOW_ERROR_TAG, { name: "ChildWorkflowError", }).namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError(CHILD_WORKFLOW_ERROR_TAG, { name: "ChildWorkflowError", }).stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
workflowNamereadonlystringTaggedError(CHILD_WORKFLOW_ERROR_TAG, { name: "ChildWorkflowError", }).workflowNamepackages/worker/src/errors.ts:415

ChildWorkflowNotFoundError ​

Defined in: packages/worker/src/errors.ts:386

Error thrown when a child workflow is not found in the contract

Extends ​

  • TaggedErrorInstance<"@temporal-contract/ChildWorkflowNotFoundError", { availableWorkflows: readonly string[]; workflowName: string; }>

Constructors ​

Constructor ​
ts
new ChildWorkflowNotFoundError(workflowName, availableWorkflows?): ChildWorkflowNotFoundError;

Defined in: packages/worker/src/errors.ts:392

Parameters ​
ParameterTypeDefault value
workflowNamestringundefined
availableWorkflowsreadonly string[][]
Returns ​

ChildWorkflowNotFoundError

Overrides ​
ts
TaggedError(CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG, {
  name: "ChildWorkflowNotFoundError",
})<{
  workflowName: string;
  availableWorkflows: readonly string[];
}>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"@temporal-contract/ChildWorkflowNotFoundError"TaggedError(CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG, { name: "ChildWorkflowNotFoundError", })._tagnode_modules/.pnpm/unthrown@5.7.0/node_modules/unthrown/dist/index.d.mts:2011
availableWorkflowsreadonlyreadonly string[]TaggedError(CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG, { name: "ChildWorkflowNotFoundError", }).availableWorkflowspackages/worker/src/errors.ts:390
cause?publicunknownTaggedError(CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG, { name: "ChildWorkflowNotFoundError", }).causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError(CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG, { name: "ChildWorkflowNotFoundError", }).messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError(CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG, { name: "ChildWorkflowNotFoundError", }).namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError(CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG, { name: "ChildWorkflowNotFoundError", }).stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
workflowNamereadonlystringTaggedError(CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG, { name: "ChildWorkflowNotFoundError", }).workflowNamepackages/worker/src/errors.ts:389

ContractMisuseError ​

Defined in: packages/worker/src/errors.ts:306

Error thrown when workflow-sandbox code misuses the contract surface, at one of two different points with two different runtime consequences:

  • Binding a signal/query/update handler for a name the contract doesn't declare, or using an async-validating schema where Temporal requires synchronous validation. These throw from inside the running implementation — handleSignal/handleQuery/handleUpdate execute there, after Temporal has already invoked the workflow function — so the throw is classified as a normal workflow failure and fails the Workflow Execution terminally with a clear message, the same way throw context.errors.X(...) does. A plain Error at that point would instead be classified as a Workflow Task failure and retried indefinitely, leaving the execution silently Running forever — this is the case ValidationError's siblings all guard against, and it's genuinely true here.
  • Reaching an activity that no options cover (see buildRawActivitiesProxy in internal.ts). This one is different: it throws at module top level, inside declareWorkflow itself, before Temporal ever invokes the workflow function. A throw there is a Workflow Task failure regardless of the error class — nonRetryable never reaches a FailWorkflowExecution command from this path — so it stalls the workflow via indefinite workflow-task retry exactly like the plain TypeError it replaces. That is deliberate (see activity-bounds.ts); the value here is a typed, named, greppable failure, not a different retry outcome.

Extends ValidationError for family consistency with its siblings (a schema-validation failure at the wire boundary), even though the second case above doesn't share their retry-outcome rationale.

Carries no schema issues (the misuse is structural, not a payload validation failure), so the issues array is always empty.

Extends ​

Constructors ​

Constructor ​
ts
new ContractMisuseError(message): ContractMisuseError;

Defined in: packages/worker/src/errors.ts:307

Parameters ​
ParameterType
messagestring
Returns ​

ContractMisuseError

Overrides ​
ts
ValidationError.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
category?readonly"BENIGN" | null-ValidationError.categorynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:113
cause?readonlyError-ValidationError.causenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:72
details?readonlyunknown[] | null-ValidationError.detailsnode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:111
failure?publicIFailureThe original failure that constructed this error. Only present if this error was generated from an external operation.ValidationError.failurenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:78
issuesreadonlyreadonly Issue[]-ValidationError.issuespackages/worker/src/errors.ts:61
messagepublicstring-ValidationError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-ValidationError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
nextRetryDelay?readonlyany-ValidationError.nextRetryDelaynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:112
nonRetryable?readonlyboolean | null-ValidationError.nonRetryablenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:110
stack?publicstring-ValidationError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
type?readonlystring | null-ValidationError.typenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:109
stackTraceLimitstaticnumberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.ValidationError.stackTraceLimitnode_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:67

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:51

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​

ValidationError.captureStackTrace

create() ​
ts
static create(options): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:130

Create a new ApplicationFailure.

By default, will be retryable (unless its type is included in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterType
optionsApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.create

fromError() ​
ts
static fromError(error, overrides?): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:124

Create a new ApplicationFailure from an Error object.

First calls ensureApplicationFailure | `ensureApplicationFailure(error)` and then overrides any fields provided in overrides.

Parameters ​
ParameterType
errorunknown
overrides?ApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.fromError

nonRetryable() ​
ts
static nonRetryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:150

Get a new ApplicationFailure with the nonRetryable flag set to true.

When thrown from an Activity or Workflow, the Activity or Workflow will not be retried (even if type is not listed in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.nonRetryable

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:55

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​

ValidationError.prepareStackTrace

retryable() ​
ts
static retryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:139

Get a new ApplicationFailure with the nonRetryable flag set to false. Note that this error will still not be retried if its type is included in RetryPolicy.nonRetryableErrorTypes.

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type (used by RetryPolicy.nonRetryableErrorTypes)
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.retryable


QueryInputValidationError ​

Defined in: packages/worker/src/errors.ts:188

Error thrown when query input validation fails.

Extends ​

Constructors ​

Constructor ​
ts
new QueryInputValidationError(queryName, issues): QueryInputValidationError;

Defined in: packages/worker/src/errors.ts:191

Parameters ​
ParameterType
queryNamestring
issuesreadonly Issue[]
Returns ​

QueryInputValidationError

Overrides ​
ts
ValidationError.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
category?readonly"BENIGN" | null-ValidationError.categorynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:113
cause?readonlyError-ValidationError.causenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:72
details?readonlyunknown[] | null-ValidationError.detailsnode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:111
directionreadonly"input"--packages/worker/src/errors.ts:189
failure?publicIFailureThe original failure that constructed this error. Only present if this error was generated from an external operation.ValidationError.failurenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:78
issuesreadonlyreadonly Issue[]-ValidationError.issuespackages/worker/src/errors.ts:61
messagepublicstring-ValidationError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-ValidationError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
nextRetryDelay?readonlyany-ValidationError.nextRetryDelaynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:112
nonRetryable?readonlyboolean | null-ValidationError.nonRetryablenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:110
queryNamereadonlystring--packages/worker/src/errors.ts:192
stack?publicstring-ValidationError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
type?readonlystring | null-ValidationError.typenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:109
stackTraceLimitstaticnumberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.ValidationError.stackTraceLimitnode_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:67

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:51

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​

ValidationError.captureStackTrace

create() ​
ts
static create(options): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:130

Create a new ApplicationFailure.

By default, will be retryable (unless its type is included in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterType
optionsApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.create

fromError() ​
ts
static fromError(error, overrides?): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:124

Create a new ApplicationFailure from an Error object.

First calls ensureApplicationFailure | `ensureApplicationFailure(error)` and then overrides any fields provided in overrides.

Parameters ​
ParameterType
errorunknown
overrides?ApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.fromError

nonRetryable() ​
ts
static nonRetryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:150

Get a new ApplicationFailure with the nonRetryable flag set to true.

When thrown from an Activity or Workflow, the Activity or Workflow will not be retried (even if type is not listed in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.nonRetryable

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:55

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​

ValidationError.prepareStackTrace

retryable() ​
ts
static retryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:139

Get a new ApplicationFailure with the nonRetryable flag set to false. Note that this error will still not be retried if its type is included in RetryPolicy.nonRetryableErrorTypes.

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type (used by RetryPolicy.nonRetryableErrorTypes)
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.retryable


QueryOutputValidationError ​

Defined in: packages/worker/src/errors.ts:204

Error thrown when query output validation fails.

Extends ​

Constructors ​

Constructor ​
ts
new QueryOutputValidationError(queryName, issues): QueryOutputValidationError;

Defined in: packages/worker/src/errors.ts:207

Parameters ​
ParameterType
queryNamestring
issuesreadonly Issue[]
Returns ​

QueryOutputValidationError

Overrides ​
ts
ValidationError.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
category?readonly"BENIGN" | null-ValidationError.categorynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:113
cause?readonlyError-ValidationError.causenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:72
details?readonlyunknown[] | null-ValidationError.detailsnode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:111
directionreadonly"output"--packages/worker/src/errors.ts:205
failure?publicIFailureThe original failure that constructed this error. Only present if this error was generated from an external operation.ValidationError.failurenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:78
issuesreadonlyreadonly Issue[]-ValidationError.issuespackages/worker/src/errors.ts:61
messagepublicstring-ValidationError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-ValidationError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
nextRetryDelay?readonlyany-ValidationError.nextRetryDelaynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:112
nonRetryable?readonlyboolean | null-ValidationError.nonRetryablenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:110
queryNamereadonlystring--packages/worker/src/errors.ts:208
stack?publicstring-ValidationError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
type?readonlystring | null-ValidationError.typenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:109
stackTraceLimitstaticnumberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.ValidationError.stackTraceLimitnode_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:67

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:51

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​

ValidationError.captureStackTrace

create() ​
ts
static create(options): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:130

Create a new ApplicationFailure.

By default, will be retryable (unless its type is included in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterType
optionsApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.create

fromError() ​
ts
static fromError(error, overrides?): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:124

Create a new ApplicationFailure from an Error object.

First calls ensureApplicationFailure | `ensureApplicationFailure(error)` and then overrides any fields provided in overrides.

Parameters ​
ParameterType
errorunknown
overrides?ApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.fromError

nonRetryable() ​
ts
static nonRetryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:150

Get a new ApplicationFailure with the nonRetryable flag set to true.

When thrown from an Activity or Workflow, the Activity or Workflow will not be retried (even if type is not listed in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.nonRetryable

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:55

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​

ValidationError.prepareStackTrace

retryable() ​
ts
static retryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:139

Get a new ApplicationFailure with the nonRetryable flag set to false. Note that this error will still not be retried if its type is included in RetryPolicy.nonRetryableErrorTypes.

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type (used by RetryPolicy.nonRetryableErrorTypes)
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.retryable


UpdateInputValidationError ​

Defined in: packages/worker/src/errors.ts:220

Error thrown when update input validation fails.

Extends ​

Constructors ​

Constructor ​
ts
new UpdateInputValidationError(updateName, issues): UpdateInputValidationError;

Defined in: packages/worker/src/errors.ts:223

Parameters ​
ParameterType
updateNamestring
issuesreadonly Issue[]
Returns ​

UpdateInputValidationError

Overrides ​
ts
ValidationError.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
category?readonly"BENIGN" | null-ValidationError.categorynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:113
cause?readonlyError-ValidationError.causenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:72
details?readonlyunknown[] | null-ValidationError.detailsnode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:111
directionreadonly"input"--packages/worker/src/errors.ts:221
failure?publicIFailureThe original failure that constructed this error. Only present if this error was generated from an external operation.ValidationError.failurenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:78
issuesreadonlyreadonly Issue[]-ValidationError.issuespackages/worker/src/errors.ts:61
messagepublicstring-ValidationError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-ValidationError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
nextRetryDelay?readonlyany-ValidationError.nextRetryDelaynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:112
nonRetryable?readonlyboolean | null-ValidationError.nonRetryablenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:110
stack?publicstring-ValidationError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
type?readonlystring | null-ValidationError.typenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:109
updateNamereadonlystring--packages/worker/src/errors.ts:224
stackTraceLimitstaticnumberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.ValidationError.stackTraceLimitnode_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:67

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:51

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​

ValidationError.captureStackTrace

create() ​
ts
static create(options): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:130

Create a new ApplicationFailure.

By default, will be retryable (unless its type is included in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterType
optionsApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.create

fromError() ​
ts
static fromError(error, overrides?): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:124

Create a new ApplicationFailure from an Error object.

First calls ensureApplicationFailure | `ensureApplicationFailure(error)` and then overrides any fields provided in overrides.

Parameters ​
ParameterType
errorunknown
overrides?ApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.fromError

nonRetryable() ​
ts
static nonRetryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:150

Get a new ApplicationFailure with the nonRetryable flag set to true.

When thrown from an Activity or Workflow, the Activity or Workflow will not be retried (even if type is not listed in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.nonRetryable

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:55

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​

ValidationError.prepareStackTrace

retryable() ​
ts
static retryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:139

Get a new ApplicationFailure with the nonRetryable flag set to false. Note that this error will still not be retried if its type is included in RetryPolicy.nonRetryableErrorTypes.

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type (used by RetryPolicy.nonRetryableErrorTypes)
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.retryable


UpdateOutputValidationError ​

Defined in: packages/worker/src/errors.ts:236

Error thrown when update output validation fails.

Extends ​

Constructors ​

Constructor ​
ts
new UpdateOutputValidationError(updateName, issues): UpdateOutputValidationError;

Defined in: packages/worker/src/errors.ts:239

Parameters ​
ParameterType
updateNamestring
issuesreadonly Issue[]
Returns ​

UpdateOutputValidationError

Overrides ​
ts
ValidationError.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
category?readonly"BENIGN" | null-ValidationError.categorynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:113
cause?readonlyError-ValidationError.causenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:72
details?readonlyunknown[] | null-ValidationError.detailsnode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:111
directionreadonly"output"--packages/worker/src/errors.ts:237
failure?publicIFailureThe original failure that constructed this error. Only present if this error was generated from an external operation.ValidationError.failurenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:78
issuesreadonlyreadonly Issue[]-ValidationError.issuespackages/worker/src/errors.ts:61
messagepublicstring-ValidationError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-ValidationError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
nextRetryDelay?readonlyany-ValidationError.nextRetryDelaynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:112
nonRetryable?readonlyboolean | null-ValidationError.nonRetryablenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:110
stack?publicstring-ValidationError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
type?readonlystring | null-ValidationError.typenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:109
updateNamereadonlystring--packages/worker/src/errors.ts:240
stackTraceLimitstaticnumberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.ValidationError.stackTraceLimitnode_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:67

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:51

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​

ValidationError.captureStackTrace

create() ​
ts
static create(options): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:130

Create a new ApplicationFailure.

By default, will be retryable (unless its type is included in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterType
optionsApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.create

fromError() ​
ts
static fromError(error, overrides?): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:124

Create a new ApplicationFailure from an Error object.

First calls ensureApplicationFailure | `ensureApplicationFailure(error)` and then overrides any fields provided in overrides.

Parameters ​
ParameterType
errorunknown
overrides?ApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.fromError

nonRetryable() ​
ts
static nonRetryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:150

Get a new ApplicationFailure with the nonRetryable flag set to true.

When thrown from an Activity or Workflow, the Activity or Workflow will not be retried (even if type is not listed in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.nonRetryable

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:55

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​

ValidationError.prepareStackTrace

retryable() ​
ts
static retryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:139

Get a new ApplicationFailure with the nonRetryable flag set to false. Note that this error will still not be retried if its type is included in RetryPolicy.nonRetryableErrorTypes.

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type (used by RetryPolicy.nonRetryableErrorTypes)
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.retryable


WorkflowCancelledError ​

Defined in: packages/worker/src/errors.ts:477

Error surfaced in the Err(...) branch of an AsyncResult when a typed cancellation scope is cancelled via Temporal's cancellation propagation. Returned by both context.cancellableScope (when the workflow or an ancestor scope cancels) and context.nonCancellableScope (when cancellation is raised from inside the scope). Distinct from arbitrary thrown errors so call sites can branch on cancellation explicitly.

Non-cancellation errors thrown inside a scope are unmodeled failures: they surface on the scope's defect channel (re-thrown at the edge / inspectable via result.isDefect() and result.cause), not as a typed Err(...).

Swallowing this error changes the workflow outcome. Cancellation rides the modeled Err(...) channel here, so generic error handling (e.g. mapping every Err to a "failed" result and returning normally) makes the workflow complete as Completed instead of Cancelled. When the workflow should honor the cancellation request after cleanup, re-raise it with rethrowCancellation.

Extends ​

  • TaggedErrorInstance<"@temporal-contract/WorkflowCancelledError", { cause?: unknown; }>

Constructors ​

Constructor ​
ts
new WorkflowCancelledError(cause?): WorkflowCancelledError;

Defined in: packages/worker/src/errors.ts:482

Parameters ​
ParameterType
cause?unknown
Returns ​

WorkflowCancelledError

Overrides ​
ts
TaggedError(WORKFLOW_CANCELLED_ERROR_TAG, {
  name: "WorkflowCancelledError",
})<{
  cause?: unknown;
}>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"@temporal-contract/WorkflowCancelledError"TaggedError(WORKFLOW_CANCELLED_ERROR_TAG, { name: "WorkflowCancelledError", })._tagnode_modules/.pnpm/unthrown@5.7.0/node_modules/unthrown/dist/index.d.mts:2011
cause?publicunknownActivityDefinitionNotFoundError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError(WORKFLOW_CANCELLED_ERROR_TAG, { name: "WorkflowCancelledError", }).messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError(WORKFLOW_CANCELLED_ERROR_TAG, { name: "WorkflowCancelledError", }).namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError(WORKFLOW_CANCELLED_ERROR_TAG, { name: "WorkflowCancelledError", }).stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

WorkflowInputValidationError ​

Defined in: packages/worker/src/errors.ts:156

Error thrown when workflow input validation fails.

Extends ​

Constructors ​

Constructor ​
ts
new WorkflowInputValidationError(workflowName, issues): WorkflowInputValidationError;

Defined in: packages/worker/src/errors.ts:159

Parameters ​
ParameterType
workflowNamestring
issuesreadonly Issue[]
Returns ​

WorkflowInputValidationError

Overrides ​
ts
ValidationError.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
category?readonly"BENIGN" | null-ValidationError.categorynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:113
cause?readonlyError-ValidationError.causenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:72
details?readonlyunknown[] | null-ValidationError.detailsnode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:111
directionreadonly"input"--packages/worker/src/errors.ts:157
failure?publicIFailureThe original failure that constructed this error. Only present if this error was generated from an external operation.ValidationError.failurenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:78
issuesreadonlyreadonly Issue[]-ValidationError.issuespackages/worker/src/errors.ts:61
messagepublicstring-ValidationError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-ValidationError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
nextRetryDelay?readonlyany-ValidationError.nextRetryDelaynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:112
nonRetryable?readonlyboolean | null-ValidationError.nonRetryablenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:110
stack?publicstring-ValidationError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
type?readonlystring | null-ValidationError.typenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:109
workflowNamereadonlystring--packages/worker/src/errors.ts:160
stackTraceLimitstaticnumberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.ValidationError.stackTraceLimitnode_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:67

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:51

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​

ValidationError.captureStackTrace

create() ​
ts
static create(options): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:130

Create a new ApplicationFailure.

By default, will be retryable (unless its type is included in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterType
optionsApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.create

fromError() ​
ts
static fromError(error, overrides?): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:124

Create a new ApplicationFailure from an Error object.

First calls ensureApplicationFailure | `ensureApplicationFailure(error)` and then overrides any fields provided in overrides.

Parameters ​
ParameterType
errorunknown
overrides?ApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.fromError

nonRetryable() ​
ts
static nonRetryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:150

Get a new ApplicationFailure with the nonRetryable flag set to true.

When thrown from an Activity or Workflow, the Activity or Workflow will not be retried (even if type is not listed in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.nonRetryable

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:55

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​

ValidationError.prepareStackTrace

retryable() ​
ts
static retryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:139

Get a new ApplicationFailure with the nonRetryable flag set to false. Note that this error will still not be retried if its type is included in RetryPolicy.nonRetryableErrorTypes.

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type (used by RetryPolicy.nonRetryableErrorTypes)
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.retryable


WorkflowOutputValidationError ​

Defined in: packages/worker/src/errors.ts:172

Error thrown when workflow output validation fails.

Extends ​

Constructors ​

Constructor ​
ts
new WorkflowOutputValidationError(workflowName, issues): WorkflowOutputValidationError;

Defined in: packages/worker/src/errors.ts:175

Parameters ​
ParameterType
workflowNamestring
issuesreadonly Issue[]
Returns ​

WorkflowOutputValidationError

Overrides ​
ts
ValidationError.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
category?readonly"BENIGN" | null-ValidationError.categorynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:113
cause?readonlyError-ValidationError.causenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:72
details?readonlyunknown[] | null-ValidationError.detailsnode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:111
directionreadonly"output"--packages/worker/src/errors.ts:173
failure?publicIFailureThe original failure that constructed this error. Only present if this error was generated from an external operation.ValidationError.failurenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:78
issuesreadonlyreadonly Issue[]-ValidationError.issuespackages/worker/src/errors.ts:61
messagepublicstring-ValidationError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-ValidationError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
nextRetryDelay?readonlyany-ValidationError.nextRetryDelaynode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:112
nonRetryable?readonlyboolean | null-ValidationError.nonRetryablenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:110
stack?publicstring-ValidationError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
type?readonlystring | null-ValidationError.typenode_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:109
workflowNamereadonlystring--packages/worker/src/errors.ts:176
stackTraceLimitstaticnumberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.ValidationError.stackTraceLimitnode_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:67

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:51

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​

ValidationError.captureStackTrace

create() ​
ts
static create(options): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:130

Create a new ApplicationFailure.

By default, will be retryable (unless its type is included in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterType
optionsApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.create

fromError() ​
ts
static fromError(error, overrides?): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:124

Create a new ApplicationFailure from an Error object.

First calls ensureApplicationFailure | `ensureApplicationFailure(error)` and then overrides any fields provided in overrides.

Parameters ​
ParameterType
errorunknown
overrides?ApplicationFailureOptions
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.fromError

nonRetryable() ​
ts
static nonRetryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:150

Get a new ApplicationFailure with the nonRetryable flag set to true.

When thrown from an Activity or Workflow, the Activity or Workflow will not be retried (even if type is not listed in RetryPolicy.nonRetryableErrorTypes).

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.nonRetryable

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@26.4.0/node_modules/@types/node/globals.d.ts:55

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​

ValidationError.prepareStackTrace

retryable() ​
ts
static retryable(
   message?, 
   type?, 
   ...details
): ApplicationFailure;

Defined in: node_modules/.pnpm/@temporalio+common@1.23.0/node_modules/@temporalio/common/lib/failure.d.ts:139

Get a new ApplicationFailure with the nonRetryable flag set to false. Note that this error will still not be retried if its type is included in RetryPolicy.nonRetryableErrorTypes.

Parameters ​
ParameterTypeDescription
message?string | nullOptional error message
type?string | nullOptional error type (used by RetryPolicy.nonRetryableErrorTypes)
...details?unknown[]Optional details about the failure. Serialized by the Worker's PayloadConverter.
Returns ​

ApplicationFailure

Inherited from ​

ValidationError.retryable

Type Aliases ​

ActivityErrorsFor ​

ts
type ActivityErrorsFor<TActivity> = TActivity extends object ? 
  | ContractErrorUnion<TErrors>
  | ActivityError
  | ActivityCancelledError : 
  | ActivityError
  | ActivityCancelledError;

Defined in: packages/worker/src/activities-proxy.ts:41

The error channel for an activity call: declared contract errors when the activity declares an errors map, plus the two failures every activity can produce.

  • With an errors map — declared failures are rehydrated from the ApplicationFailure wire shape into typed ContractErrorUnion members (data re-validated against the declared schema).
  • Always — any other failure surfaces as ActivityError (with Temporal's ActivityFailure wrapper unwrapped to its actionable cause) or ActivityCancelledError (mirroring the child-workflow API).

Type Parameters ​

Type Parameter
TActivity extends ActivityDefinition

ContractErrorUnion ​

ts
type ContractErrorUnion<TErrors> = { [K in keyof TErrors & string]: ContractError<K, InferErrorData<TErrors[K]>> }[keyof TErrors & string];

Defined in: packages/contract/dist/errors-impl-BxWuCbUU.d.mts:79

Consumer-side union of ContractError instances for a declared errors map — data is typed with each schema's output (post-transform) shape. This is the union surfaced on the error channel of workflow-side activity calls and client-side workflow results.

Type Parameters ​

Type Parameter
TErrors extends Record<string, ErrorDefinition>

DeclareWorkflowOptions ​

ts
type DeclareWorkflowOptions<TContract, TWorkflowName> = object;

Defined in: packages/worker/src/workflow.ts:521

Options for declaring a workflow implementation

Type Parameters ​

Type Parameter
TContract extends ContractDefinition
TWorkflowName extends keyof TContract["workflows"] & string

Properties ​

PropertyTypeDescriptionDefined in
activityOptions?ActivityOptionsDefault activity options applied to every activity reachable from this workflow (workflow-local + global) unless overridden. Merge precedence per activity (least → most specific): this workflow-wide default → the activity's contract-level defineActivity({ activityOptions }) → the explicit activityOptionsByName entry. See Temporal's ActivityOptions for the full set of fields: - startToCloseTimeout: Maximum time for a single attempt to run - scheduleToCloseTimeout: End-to-end timeout including queuing and retries - scheduleToStartTimeout: Maximum time the activity can wait in the queue - heartbeatTimeout: Time between heartbeats before the activity is considered dead - retry: Retry policy for failed activities Example activityOptions: { startToCloseTimeout: '5m', retry: { maximumAttempts: 3 }, } Optional in isolation, but every activity reachable from this workflow (workflow-local + global) must end up with a bounded merged result: a per-attempt bound (startToCloseTimeout or scheduleToCloseTimeout) AND a total bound (scheduleToCloseTimeout, or a finite positive retry.maximumAttempts) — otherwise a failing activity retries forever. This is checked unconditionally on the MERGE of all three layers (activityOptions → the activity's contract-level defineActivity({ activityOptions }) → activityOptionsByName), not on any single layer in isolation: since each layer shallow-merges over the previous — replacing a retry block wholesale, not field-by-field — two individually-bounded layers can still merge to something unbounded. Supplying activityOptions here does not exempt an activity that carries its own contract-level or per-name options; if the FINAL merged result for any reachable activity is missing either bound, declareWorkflow throws ContractMisuseError at declaration time (workflow-bundle load), naming every offending activity and which bound(s) it lacks.packages/worker/src/workflow.ts:567
activityOptionsByName?Partial<Record<ActivityNamesFor<TContract, TWorkflowName>, ActivityOptions>>Per-activity ActivityOptions overrides. Each entry shallow-merges over activityOptions for that activity only — the override wins on every property it specifies, replacing the default value (including the entire nested retry block when present, matching Temporal's single-options-per-proxyActivities-call semantics). The override value is Temporal's full ActivityOptions, so any field is fair game — including taskQueue, which lets you route individual activities to dedicated worker pools (e.g. concurrency-capped queues for LLM calls) while the rest of the workflow's activities stay on the default queue. This keeps the Zod-validated typed-activities boundary intact, where a raw proxyActivities({ taskQueue }) would forfeit it. Activity names are typed against the contract; typos surface as TypeScript errors rather than running silently with the default options. Examples Tune timeouts and retries per activity // default — both bounds live here; fastValidationbelow only // overridesstartToCloseTimeout, so it still inherits this retry. activityOptions: { startToCloseTimeout: '1 minute', retry: { maximumAttempts: 3 } }, activityOptionsByName: { chargePayment: { startToCloseTimeout: '5 minutes', retry: { maximumAttempts: 5 }, }, fastValidation: { startToCloseTimeout: '5 seconds' }, }, Route specific activities to a dedicated task queue // default — both bounds live here; the taskQueue-only override below // still inherits this retry. activityOptions: { startToCloseTimeout: '10 minutes', retry: { maximumAttempts: 3 } }, // default queue activityOptionsByName: { // LLM call → dedicated, concurrency-capped queue. extractLayoutChunk: { taskQueue: 'gemini-pro' }, // finalizeLayout, extractImages, … fall through to the default queue. },packages/worker/src/workflow.ts:611
contractTContract-packages/worker/src/workflow.ts:526
implementationWorkflowImplementation<TContract, TWorkflowName>-packages/worker/src/workflow.ts:527
workflowNameTWorkflowName-packages/worker/src/workflow.ts:525

QueryHandlerImplementation ​

ts
type QueryHandlerImplementation<TQuery> = (args) => WorkerInferOutput<TQuery>;

Defined in: packages/worker/src/handlers.ts:47

Query handler implementation

Processes query input and returns a synchronous response. Must be synchronous to satisfy Temporal's query constraints.

Type Parameters ​

Type Parameter
TQuery extends QueryDefinition

Parameters ​

ParameterType
argsWorkerInferInput<TQuery>

Returns ​

WorkerInferOutput<TQuery>


SignalHandlerImplementation ​

ts
type SignalHandlerImplementation<TSignal> = (args) => void | Promise<void>;

Defined in: packages/worker/src/handlers.ts:37

Signal handler implementation

Processes signal input and can optionally perform asynchronous operations. Should not return a value (signals are fire-and-forget).

Type Parameters ​

Type Parameter
TSignal extends SignalDefinition

Parameters ​

ParameterType
argsWorkerInferInput<TSignal>

Returns ​

void | Promise<void>


TypedChildWorkflowHandle ​

ts
type TypedChildWorkflowHandle<TWorkflow> = object;

Defined in: packages/worker/src/child-workflow.ts:81

Typed handle for a child workflow with unthrown AsyncResult pattern.

Type Parameters ​

Type Parameter
TWorkflow extends AnyWorkflowDefinition

Properties ​

PropertyTypeDescriptionDefined in
firstExecutionRunIdstringRun ID of the child's first execution — the anchor of its execution chain (stable across continue-as-new), mirroring the field Temporal exposes on its own ChildWorkflowHandle.packages/worker/src/child-workflow.ts:106
result() => AsyncResult<ClientInferOutput<TWorkflow>, | ChildWorkflowError | ChildWorkflowCancelledError>Get child workflow result with AsyncResult pattern.packages/worker/src/child-workflow.ts:85
signalsTypedChildWorkflowSignals<TWorkflow>Typed signal senders for the child's declared signals — see TypedChildWorkflowSignals. Empty when the child declares none.packages/worker/src/child-workflow.ts:94
workflowIdstringChild workflow ID.packages/worker/src/child-workflow.ts:99

TypedChildWorkflowOptions ​

ts
type TypedChildWorkflowOptions<TChildContract, TChildWorkflowName> = Omit<ChildWorkflowOptions, "taskQueue" | "args" | "parentClosePolicy"> & object;

Defined in: packages/worker/src/child-workflow.ts:53

Options for starting a child workflow. taskQueue and args come from the contract, which also supplies a default workflowIdReusePolicy derived from the target workflow's declared startPolicy mode; everything else — including an explicit workflowIdReusePolicy here, which overrides that default — is forwarded to Temporal's startChild / executeChild.

parentClosePolicy is required. Temporal's default is TERMINATE: when the parent closes, the child is killed — mid-payment included. That default is fine when chosen and dangerous when inherited, so it must be stated. TERMINATE remains available; it simply has to be written down.

The Exclude is load-bearing. The SDK's ParentClosePolicy union contains undefined (via the deprecated PARENT_CLOSE_POLICY_UNSPECIFIED member), so a bare required field would still accept undefined and require nothing.

Type Declaration ​

NameTypeDefined in
argsClientInferInput<TChildContract["workflows"][TChildWorkflowName]>packages/worker/src/child-workflow.ts:57
parentClosePolicyExclude<ParentClosePolicy, undefined>packages/worker/src/child-workflow.ts:58

Type Parameters ​

Type Parameter
TChildContract extends ContractDefinition
TChildWorkflowName extends keyof TChildContract["workflows"] & string

TypedChildWorkflowSignals ​

ts
type TypedChildWorkflowSignals<TWorkflow> = { [K in InferSignalNames<TWorkflow>]: (args: ClientInferInput<SignalDefOf<TWorkflow, K>>) => AsyncResult<void, ChildWorkflowError | ChildWorkflowCancelledError> };

Defined in: packages/worker/src/child-workflow.ts:72

Typed signal senders for a child workflow, keyed by the signal names declared on the child's contract entry. Mirrors the shape of the typed client handle's signals proxy: one function per declared signal, taking the signal's (client-perspective) input and returning an AsyncResult.

Per the wire-format rule (D1), the sender validates args against the signal's input schema — failing early with Err(ChildWorkflowError) — but transmits the caller's ORIGINAL value; the child's signal handler parses it on receive, so a transforming schema applies exactly once.

Type Parameters ​

Type Parameter
TWorkflow extends AnyWorkflowDefinition

TypedContinueAsNewOptions ​

ts
type TypedContinueAsNewOptions = Omit<ContinueAsNewOptions, "workflowType" | "taskQueue">;

Defined in: packages/worker/src/internal.ts:264

Continue-as-new options the typed wrapper does not own. workflowType and taskQueue are derived from the contract; everything else is forwarded to Temporal's makeContinueAsNewFunc.


UpdateHandlerImplementation ​

ts
type UpdateHandlerImplementation<TUpdate> = (args) => Promise<WorkerInferOutput<TUpdate>>;

Defined in: packages/worker/src/handlers.ts:57

Update handler implementation

Processes update input and returns a validated response after modifying workflow state. Can perform asynchronous operations.

Type Parameters ​

Type Parameter
TUpdate extends UpdateDefinition

Parameters ​

ParameterType
argsWorkerInferInput<TUpdate>

Returns ​

Promise<WorkerInferOutput<TUpdate>>


WorkflowContext ​

ts
type WorkflowContext<TContract, TWorkflowName> = object;

Defined in: packages/worker/src/workflow.ts:649

Type Parameters ​

Type Parameter
TContract extends ContractDefinition
TWorkflowName extends keyof TContract["workflows"] & string

Properties ​

PropertyTypeDescriptionDefined in
activitiesReadonly<WorkflowInferWorkflowContextActivities<TContract, TWorkflowName>>-packages/worker/src/workflow.ts:653
cancellableScope<T>(fn) => AsyncResult<T, WorkflowCancelledError>Run fn inside a cancellable Temporal scope. If the workflow (or an ancestor scope) is cancelled while fn is in flight, the resulting AsyncResult resolves to Err(WorkflowCancelledError) instead of rejecting — letting callers handle cancellation explicitly, typically to perform a graceful exit from the current step. Non-cancellation errors thrown by fn are unmodeled failures: they ride unthrown's defect channel (inspectable via result.isDefect() / result.cause, re-thrown at the edge), keeping the modeled error channel to the single anticipated outcome — cancellation. Example implementation: async (context, args) => { const result = await context.cancellableScope(async () => { // fn's return value becomes the scope's Tverbatim, so await and // narrow the activity's own AsyncResult HERE, inside the callback. //AsyncResultis deliberately not a fullPromiseLike(no //.catch/.finally), so returning an un-awaited activity call // would make Tthe un-awaitedAsyncResultitself — which has no //isOk/isErr/.value(only the plainResultyou get by // awaiting does). const step = await context.activities.processStep(args); if (step.isDefect()) { throw step.cause; // an unmodeled bug — surfaces as the scope's own defect } return step.isOk() ? { status: "ok" as const } : { status: "failed" as const }; }); if (result.isDefect()) { throw result.cause; // a genuine bug thrown inside the scope, not a cancel } if (result.isErr()) { // The scope itself was cancelled — perform cleanup that must not be // cancelled. Capture nonCancellableScope's OWN AsyncResult too — a // bareawait here would silently discard a defect thrown inside // the cleanup callback. const released = await context.nonCancellableScope(async () => { const step = await context.activities.releaseResources(args); if (step.isErr()) { // best-effort cleanup — log and continue regardless } }); if (released.isDefect()) { throw released.cause; // a genuine bug in cleanup, not a cancel } return { status: "cancelled" }; } return result.value; }packages/worker/src/workflow.ts:927
continueAsNew{ (args, options?): Promise<never>; <TOtherContract, TOtherWorkflowName> (contract, workflowName, args, options?): Promise<never>; }Continue this workflow execution as a new run, optionally with a different workflow type from another contract. Args are validated against the destination workflow's input schema before Temporal's continueAsNew is invoked. On validation failure, throws a WorkflowInputValidationError; on success, Temporal terminates the current execution and starts a fresh one — which is why the function never returns normally (Promise<never>). Idiomatic usage: Example // Same workflow, validated args implementation: async (context, args) => { if (shouldRoll(args)) { return context.continueAsNew({ ...args, retryCount: args.retryCount + 1 }); } return ...; } // Cross-contract continueAsNew (less common — taskQueue and workflow type // come from the other contract) return context.continueAsNew(otherContract, "otherWorkflow", { ...newArgs });packages/worker/src/workflow.ts:1002
errorsWorkflowErrorConstructorsOf<TContract["workflows"][TWorkflowName]>Typed constructors for the errors declared on this workflow's contract entry (defineWorkflow({ errors: {...} })). Throwing one fails the execution with a typed, schema-validated failure the client rehydrates into a ContractError: Example implementation: async (context, args) => { if (!args.items.length) { throw context.errors.EmptyOrder({ orderId: args.orderId }); } // ... }packages/worker/src/workflow.ts:672
executeChildWorkflow<TChildContract, TChildWorkflowName>(contract, workflowName, options) => AsyncResult<ClientInferOutput<TChildContract["workflows"][TChildWorkflowName]>, | ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>Execute a child workflow (start and wait for result) with AsyncResult pattern The contract argument is always required — it identifies the task queue and workflow definition the child runs against, and supplies the workflowIdReusePolicy from the target workflow's declared startPolicy mode: - Same-contract child: pass this worker's own contract and one of its workflow names. - Cross-contract child: pass another worker's contract to invoke a workflow it serves (the child's task queue comes from that contract). An explicit workflowIdReusePolicy in options overrides the contract's mode for this call only. Example import { P } from "unthrown"; // Same contract child workflow const result = await context.executeChildWorkflow(myContract, 'processPayment', { workflowId: 'payment-123', args: { amount: 100 }, parentClosePolicy: 'TERMINATE' }); // Cross-contract child workflow (from another worker) const otherResult = await context.executeChildWorkflow(otherContract, 'sendNotification', { workflowId: 'notification-123', args: { message: 'Hello' }, parentClosePolicy: 'TERMINATE' }); await result.match({ ok: (output) => console.log('Payment processed:', output), errCases: (matcher) => matcher.with( P.tag('@temporal-contract/ChildWorkflowError'), P.tag('@temporal-contract/ChildWorkflowCancelledError'), P.tag('@temporal-contract/ChildWorkflowNotFoundError'), (error) => console.error('Processing failed:', error), ), defect: (cause) => console.error('Unexpected failure:', cause), });packages/worker/src/workflow.ts:860
handleQuery<K>(queryName, handler) => voidBind a query handler within the workflow implementation (handle* — the in-workflow binding tier of the verb convention). Allows the query handler to access workflow state. Both query schemas (input and output) must validate synchronously — Temporal runs query handlers synchronously. An async-validating schema (e.g. zod async refine) trips a ContractMisuseError at bind time. Example implementation: async (context, args) => { let currentValue = args.initialValue; context.handleQuery('getCurrentValue', () => { return { value: currentValue }; }); // ... rest of workflow }packages/worker/src/workflow.ts:719
handleSignal<K>(signalName, handler) => voidBind a signal handler within the workflow implementation (handle* — the in-workflow binding tier of the verb convention). Allows the signal handler to access workflow state. Example implementation: async (context, args) => { let currentValue = args.initialValue; context.handleSignal('increment', async (signalArgs) => { currentValue += signalArgs.amount; }); // ... rest of workflow }packages/worker/src/workflow.ts:692
handleUpdate<K>(updateName, handler) => voidBind an update handler within the workflow implementation (handle* — the in-workflow binding tier of the verb convention). Allows the update handler to access and modify workflow state. The update's input schema must validate synchronously — it feeds Temporal's synchronous update validator slot. An async-validating schema trips a ContractMisuseError at bind time (the output schema may be async; it runs inside the handler body). Example implementation: async (context, args) => { let currentValue = args.initialValue; context.handleUpdate('multiply', async (updateArgs) => { currentValue *= updateArgs.factor; return { newValue: currentValue }; }); // ... rest of workflow }packages/worker/src/workflow.ts:748
infoWorkflowInfo-packages/worker/src/workflow.ts:654
nonCancellableScope<T>(fn) => AsyncResult<T, WorkflowCancelledError>Run fn inside a non-cancellable Temporal scope. Cancellation requests from outside the scope are ignored for its duration — the idiomatic way to perform cleanup work that must not be interrupted. Returns the same AsyncResult<...> shape as WorkflowContext.cancellableScope for symmetry; the Err(WorkflowCancelledError) branch only triggers when cancellation is raised from inside the scope, which is rare. Non-cancellation errors surface on the defect channel.packages/worker/src/workflow.ts:940
saga(options?) => WorkflowSagaBuilder<undefined, never>Open a saga: a sequence of steps whose compensations are unwound LIFO when a later step fails. The undos run on a declared contract error — a permanent domain answer, where what the step did before saying no is knowable. They do NOT run on an ActivityError, a ChildWorkflowError or a defect: an activity that failed unmodelled left state nobody can see, and un-deciding what you cannot see is a second bug. That failure propagates untouched, so propagateFailure still re-raises Temporal's original failure. Cancellation is the one case a caller may opt back in to, with saga({ compensateOnCancellation: true }). Every undo runs inside a non-cancellable scope, so a cancellation cannot interrupt the walk-back it triggered. Example const fulfilled = await context .saga() .step( () => context.activities.reserveStock(order), (reservation) => context.activities.releaseStock({ id: reservation.id }), ) .step( () => context.activities.chargeCard(order), (charge) => context.activities.refund({ id: charge.id }), ) .step(() => context.activities.ship(order)) .run();packages/worker/src/workflow.ts:973
startChildWorkflow<TChildContract, TChildWorkflowName>(contract, workflowName, options) => AsyncResult<TypedChildWorkflowHandle<TChildContract["workflows"][TChildWorkflowName]>, | ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>Start a child workflow and return a typed handle with AsyncResult pattern The contract argument is always required — it identifies the task queue and workflow definition the child runs against, and supplies the workflowIdReusePolicy from the target workflow's declared startPolicy mode: - Same-contract child: pass this worker's own contract and one of its workflow names. - Cross-contract child: pass another worker's contract to invoke a workflow it serves (the child's task queue comes from that contract). An explicit workflowIdReusePolicy in options overrides the contract's mode for this call only. Example import { P } from "unthrown"; // Same contract child workflow const childResult = await context.startChildWorkflow(myContract, 'processPayment', { workflowId: 'payment-123', args: { amount: 100 }, parentClosePolicy: 'TERMINATE' }); // Cross-contract child workflow (from another worker) const otherResult = await context.startChildWorkflow(otherContract, 'sendNotification', { workflowId: 'notification-123', args: { message: 'Hello' }, parentClosePolicy: 'TERMINATE' }); await childResult.match({ ok: async (handle) => { const result = await handle.result(); // ... handle result }, errCases: (matcher) => matcher.with( P.tag('@temporal-contract/ChildWorkflowError'), P.tag('@temporal-contract/ChildWorkflowCancelledError'), P.tag('@temporal-contract/ChildWorkflowNotFoundError'), (error) => console.error('Failed to start:', error), ), defect: (cause) => console.error('Unexpected failure:', cause), });packages/worker/src/workflow.ts:802

WorkflowImplementation ​

ts
type WorkflowImplementation<TContract, TWorkflowName> = (context, args) => Promise<WorkerInferOutput<TContract["workflows"][TWorkflowName]>>;

Defined in: packages/worker/src/workflow.ts:622

Workflow implementation function

Receives a workflow context (with typed activities and utilities) and validated input arguments. Returns the workflow output which will be validated against the contract schema.

Type Parameters ​

Type Parameter
TContract extends ContractDefinition
TWorkflowName extends keyof TContract["workflows"] & string

Parameters ​

ParameterType
contextWorkflowContext<TContract, TWorkflowName>
argsWorkerInferInput<TContract["workflows"][TWorkflowName]>

Returns ​

Promise<WorkerInferOutput<TContract["workflows"][TWorkflowName]>>


WorkflowInferActivity ​

ts
type WorkflowInferActivity<TActivity> = (args) => AsyncResult<ClientInferOutput<TActivity>, ActivityErrorsFor<TActivity>>;

Defined in: packages/worker/src/activities-proxy.ts:61

Activity function signature from workflow execution perspective.

Workflows call activities with the input schema's input type and receive the output schema's output (parsed) type: the workflow side validates the input but transmits the original value (the activity worker parses it on receive), and parses the activity's result on receive.

Every activity call returns an AsyncResult — the call convention no longer depends on whether the contract declared errors, only the error channel does. To let a failure escape and have Temporal decide the workflow's outcome, use propagateFailure rather than unthrown's .getOrThrow(); see that function's documentation for why.

Type Parameters ​

Type Parameter
TActivity extends ActivityDefinition

Parameters ​

ParameterType
argsClientInferInput<TActivity>

Returns ​

AsyncResult<ClientInferOutput<TActivity>, ActivityErrorsFor<TActivity>>


WorkflowInferWorkflowContextActivities ​

ts
type WorkflowInferWorkflowContextActivities<TContract, TWorkflowName> = WorkflowInferWorkflowActivities<TContract["workflows"][TWorkflowName]> & WorkflowInferActivities<TContract>;

Defined in: packages/worker/src/activities-proxy.ts:90

All activities available in a workflow context (workflow execution perspective).

Combines workflow-specific activities with global contract activities.

Type Parameters ​

Type Parameter
TContract extends ContractDefinition
TWorkflowName extends keyof TContract["workflows"] & string

WorkflowSagaBuilder ​

ts
type WorkflowSagaBuilder<T, E> = object;

Defined in: packages/worker/src/saga.ts:46

The builder workflowSaga returns.

Type Parameters ​

Type ParameterDescription
Twhat the last step produced, and what run() answers.
Ethe union of every step's modeled error type.

Properties ​

PropertyModifierTypeDescriptionDefined in
runreadonly() => AsyncResult<T, E>Run the steps in order, unwinding LIFO on a failure the policy compensates.packages/worker/src/saga.ts:67
stepreadonly<T2, E2, U, E3>(run, undo?) => WorkflowSagaBuilder<T2, E | E2>Add a step, with the undo that takes it back. Remarks run is a thunk and takes no argument; undo receives the value its own step produced. Either may answer a plain Result in place of an AsyncResult, so an undo is written as the ordinary activity call it is. The undo runs only when the failure that triggered the unwind is one the policy compensates — see workflowSaga. A compensation that itself fails becomes a defect carrying its own failure, which takes precedence over the failure that triggered the unwind and fails the workflow loudly: a refund that never happened is worse news than the order that could not ship. The remaining undos still run first.packages/worker/src/saga.ts:62

WorkflowSagaOptions ​

ts
type WorkflowSagaOptions = object;

Defined in: packages/worker/src/saga.ts:24

Options for workflowSaga.

Properties ​

PropertyModifierTypeDefault valueDescriptionDefined in
compensateOnCancellation?readonlybooleanfalseAlso compensate when a step fails because the workflow, an activity or a child workflow was cancelled. Remarks Off by default: a cancelled step stopped at a point nobody observed, so un-doing what it may or may not have done is a second bug. Turn it on for a workflow whose steps hold something a cancellation must release anyway — a seat, a reservation, a lock.packages/worker/src/saga.ts:37

Functions ​

bestEffort() ​

ts
function bestEffort<T, E>(result, onFailure): Promise<T | undefined>;

Defined in: packages/worker/src/activity-failure.ts:197

Await a call whose failure is not worth ending the workflow over — a notification, a metric, an audit write — and hand that failure to onFailure instead. Returns the value on success and undefined on failure, so a caller that wants the value can still narrow it.

The counterpart to propagateFailure: that one says "let Temporal decide", this one says "log it and carry on".

Cancellation is the exception, and that is the whole point of having this as a helper. A cancelled call arrives on the modeled Err channel like any other failure, so a hand-written best-effort fold absorbs it — and a workflow that absorbs its own cancellation runs to Completed after someone asked it to stop. Every cancellation shape (ActivityCancelledError, ChildWorkflowCancelledError, WorkflowCancelledError) is re-raised through rethrowCancellation before onFailure is ever reached, so the rule is structural instead of remembered at each call site.

A Defect (an unmodeled failure — a bug) is passed to onFailure like any other: the caller has already declared this call non-critical, and a notification bug must not block an outcome that is already authoritative. Reach for propagateFailure when that is not true.

Type Parameters ​

Type Parameter
T
E

Parameters ​

ParameterType
resultAsyncResult<T, E>
onFailure(failure) => void

Returns ​

Promise<T | undefined>

Example ​

ts
await bestEffort(
  context.activities.sendNotification({ customerId, subject, message }),
  (failure) => log.warn(`notification failed: ${String(failure)}`),
);

declareWorkflow() ​

ts
function declareWorkflow<TContract, TWorkflowName>(__namedParameters): (...args) => Promise<WorkerInferOutput<TContract["workflows"][TWorkflowName]>>;

Defined in: packages/worker/src/workflow.ts:271

Create a typed workflow implementation with automatic validation

This wraps a workflow implementation with:

  • Input/output validation
  • Typed workflow context with activities
  • Workflow info access

Workflows must be defined in separate files and imported by the Temporal Worker via workflowsPath.

Type Parameters ​

Type Parameter
TContract extends ContractDefinition
TWorkflowName extends string

Parameters ​

ParameterType
__namedParametersDeclareWorkflowOptions<TContract, TWorkflowName>

Returns ​

(...args) => Promise<WorkerInferOutput<TContract["workflows"][TWorkflowName]>>

Example ​

ts
// workflows/processOrder.ts
import { declareWorkflow } from '@temporal-contract/worker/workflow';
import myContract from '../contract.js';

export const processOrder = declareWorkflow({
  workflowName: 'processOrder',
  contract: myContract,
  activityOptions: {
    startToCloseTimeout: '1 minute',
    retry: { maximumAttempts: 3 },
  },
  // Optional: override `activityOptions` for specific activities. Each
  // entry shallow-merges over the workflow default — the override wins on
  // every property it specifies, including the whole `retry` block. The
  // override is Temporal's full `ActivityOptions`, so `taskQueue` works too,
  // letting you route individual activities to a dedicated worker pool.
  //
  // Every reachable activity's MERGED options need both a per-attempt bound
  // (`startToCloseTimeout` or `scheduleToCloseTimeout`) and a total bound
  // (`scheduleToCloseTimeout`, or a finite positive `retry.maximumAttempts`)
  // — the workflow default above supplies both, so `scoreRisk` below only
  // needs to override what it's actually changing (`taskQueue`).
  activityOptionsByName: {
    chargePayment: {
      startToCloseTimeout: '5 minutes',
      retry: { maximumAttempts: 5 },
    },
    // Route this activity to a dedicated, concurrency-capped queue; it
    // still inherits the workflow default's bounds (only `taskQueue` is
    // overridden here).
    scoreRisk: { taskQueue: 'ml-inference' },
  },
  implementation: async (context, args) => {
    // context.activities: typed activities (workflow + global)
    // context.info: WorkflowInfo

    // Every activity call returns an AsyncResult with three channels —
    // narrow `isDefect()`/`isErr()` (or use `propagateFailure` to
    // let Temporal decide the outcome) before reaching `.value`.
    const inventory = await context.activities.validateInventory({
      orderId: args.orderId,
    });
    if (inventory.isDefect()) throw inventory.cause;
    if (inventory.isErr()) {
      return { orderId: args.orderId, status: 'out_of_stock' };
    }

    if (!inventory.value.available) {
      return { orderId: args.orderId, status: 'out_of_stock' };
    }

    const payment = await context.activities.chargePayment({
      customerId: args.customerId,
      amount: 100,
    });
    if (payment.isDefect()) throw payment.cause;
    if (payment.isErr()) {
      return { orderId: args.orderId, status: 'failed' };
    }

    return {
      orderId: args.orderId,
      status: payment.value.success ? 'success' : 'failed',
      transactionId: payment.value.transactionId,
    };
  },
});

Then in your worker setup:

ts
// worker.ts
import { TypedWorker, workflowsPathFromURL } from '@temporal-contract/worker/worker';
import { activities } from './activities.js';
import myContract from './contract.js';

// `TypedWorker.create` returns AsyncResult<TypedWorker, never> — setup
// failures ride the defect channel, so `.get()` unwraps directly.
const worker = await TypedWorker.create({
  contract: myContract,
  connection,
  workflowsPath: workflowsPathFromURL(import.meta.url, './workflows.js'),
  activities,
}).get();

propagateFailure() ​

ts
function propagateFailure<T, E>(result): Promise<T>;

Defined in: packages/worker/src/activity-failure.ts:115

Await an activity call and return its value, re-raising the failure so Temporal decides the workflow's fate — the workflow-side equivalent of "let it fail".

Use this instead of unthrown's .getOrThrow(). getOrThrow throws the ActivityError / ActivityCancelledError wrapper itself, which is a TaggedError and NOT a TemporalFailure. Temporal treats a non-TemporalFailure thrown from workflow code as a workflow-TASK failure and retries it indefinitely, so the workflow never fails — it stalls until its execution timeout. This helper instead re-raises the original Temporal failure that classifyActivityError observed, which is exactly what would have escaped the workflow before activity calls returned AsyncResult.

Two things are preserved on ActivityError, and they are NOT interchangeable:

  • cause — the unwrapped actionable failure (Temporal's ActivityFailure wrapper seen through). This is documented, caller-facing behavior that existing consumers narrow on, and this helper does not change it.
  • originalFailure — the value exactly as classifyActivityError caught it, before that unwrap (typically the ActivityFailure wrapper itself). This helper re-raises originalFailure (falling back to cause, then the wrapper) so the failure Temporal observes here is byte-for-byte what it would have observed had the activity call thrown directly — rethrowing cause instead would hand Temporal a bare ApplicationFailure where it previously saw an ActivityFailure, changing what a caller further up (e.g. the client's WorkflowFailedError.cause) sees.

ActivityCancelledError has no separate originalFailure: cancellation is detected before the unwrap, so its cause already holds the pre-unwrap original failure.

A declared contract error (ContractError, from an activity's errors map) is also a TaggedError, not a TemporalFailure — but, unlike ActivityError/ActivityCancelledError, rethrowing it bare does NOT stall the workflow: declareWorkflow's own top-level catch (workflow.ts) recognizes error instanceof ContractError by name and converts it via contractErrorToApplicationFailure before Temporal ever sees it. What that fallback conversion produces, though, is wrong here: it looks the error name up on the workflow's declared errors map — not the activity's, which is what this ContractError was actually rehydrated against. When the name isn't also declared on the workflow (the common case, since the error is declared on the activity), the workflow still fails terminally, but with a misleading ContractErrorDataValidationError: Error "X" is not declared on workflow "…" instead of the activity's real, typed failure. This branch exists to fix that misclassification, not to prevent a stall: it re-raises ContractError.cause, the original ApplicationFailure Temporal actually put on the wire, so the workflow fails with the real failure instead of a confusing wrong-map error message.

Fidelity nuance, stated plainly: for a declared error this means the client sees WorkflowFailedError.cause as a bare ApplicationFailure, never wrapped in Temporal's ActivityFailure — unlike the ActivityError path above, which preserves the ActivityFailure wrapper exactly. This is a deliberate asymmetry, not an inevitability: classifyActivityError still holds the original wrapper (its error parameter — the same value it hands ActivityError as originalFailure) at the point it builds a ContractError, but _internal_rehydrateContractError is only handed the already-unwrapped failure, so the wrapper is never threaded through the rehydration path. A parallel originalFailure-style retention on ContractError would close this gap; that was deliberately left out of this task's scope.

A failure with nothing preserved at all rethrows the wrapper, so the error identity is never lost.

Not just activity calls — hence the name. The same non-TemporalFailure-stall hazard applies to context.executeChildWorkflow / context.startChildWorkflow (ChildWorkflowError, ChildWorkflowCancelledError) and to context.cancellableScope / context.nonCancellableScope (WorkflowCancelledError, whose cause holds the original CancelledFailure). This helper accepts any of those too — E is intentionally unconstrained so a bare throw error at the bottom doesn't quietly stall the workflow for a union this module didn't anticipate.

ChildWorkflowCancelledError mirrors ActivityCancelledError: every construction site (classifyChildWorkflowError) supplies cause as the pre-unwrap cancellation failure Temporal produced, so it is always safe to re-raise. ChildWorkflowError, however, does NOT uniformly mirror ActivityError: classifyChildWorkflowError's own construction sites do set cause to the unwrapped actionable failure, but three OTHER construction sites in child-workflow.ts — input validation, output validation, and signal-input validation — build a ChildWorkflowError with no cause at all, because those failures are detected locally (a schema mismatch) before any Temporal call happens, so there is no Temporal-observed failure to carry. Re-raising the bare TaggedError in that case would reproduce the exact stall this helper exists to prevent, so when cause is absent this helper converts it to a ContractMisuseError instead — the same treatment ChildWorkflowNotFoundError gets below.

ChildWorkflowNotFoundError is the other case with no cause to rethrow: it fires before any Temporal call, when the target contract doesn't declare the child workflow name at all — a deterministic programmer bug, not a Temporal-observed failure. It is converted to a ContractMisuseError (a non-retryable ApplicationFailure) instead, so it still fails the workflow terminally rather than stalling it.

Type Parameters ​

Type Parameter
T
E

Parameters ​

ParameterType
resultAsyncResult<T, E>

Returns ​

Promise<T>


rethrowCancellation() ​

ts
function rethrowCancellation(error): never;

Defined in: packages/worker/src/errors.ts:539

Re-raise a cancellation error surfaced on the modeled Err(...) channel so Temporal records the workflow execution as Cancelled.

The typed surfaces fold Temporal cancellation into Err(ActivityCancelledError | WorkflowCancelledError | ChildWorkflowCancelledError). That is deliberate — cancellation becomes an explicit branch — but it has a footgun: generic error handling that maps every Err to a domain "failed" outcome and returns normally makes the workflow complete as Completed, silently overriding the server's cancellation request. When the workflow should honor the cancellation (typically after nonCancellableScope cleanup), call this helper: it throws the original CancelledFailure carried in error.cause (or the error itself when no cause was attached), which Temporal recognizes and turns into a Cancelled workflow outcome.

Workflow-sandbox safe: no I/O, no wall clock — it only rethrows.

Parameters ​

ParameterType
error| ChildWorkflowCancelledError | WorkflowCancelledError | ActivityCancelledError

Returns ​

never

Example ​

ts
// `fn`'s return value becomes the scope's `T` verbatim, so await and
// narrow the activity's own AsyncResult HERE, inside the callback —
// returning it un-awaited would make `T` the AsyncResult itself, which
// has no `isOk`/`isErr`/`.value`.
const result = await context.cancellableScope(async () => {
  const step = await context.activities.processStep(args);
  if (step.isDefect()) {
    throw step.cause;
  }
  return step.isOk();
});
if (result.isDefect()) {
  throw result.cause; // a genuine bug thrown inside the scope, not a cancel
}
if (result.isErr()) {
  // Capture nonCancellableScope's OWN AsyncResult too — a bare `await`
  // would silently discard a defect thrown during cleanup.
  const released = await context.nonCancellableScope(async () => {
    const step = await context.activities.releaseResources(args);
    if (step.isErr()) {
      // best-effort cleanup — log and continue regardless
    }
  });
  if (released.isDefect()) {
    throw released.cause; // a genuine bug in cleanup, not a cancel
  }
  // Honor the cancellation instead of completing normally:
  rethrowCancellation(result.error);
}

workflowSaga() ​

ts
function workflowSaga(options?): WorkflowSagaBuilder<undefined, never>;

Defined in: packages/worker/src/saga.ts:138

Open a saga whose undos run only on a failure the policy compensates.

Parameters ​

ParameterType
options?WorkflowSagaOptions

Returns ​

WorkflowSagaBuilder<undefined, never>

Remarks ​

Pure control flow — no timers, no clock, no randomness — so it replays deterministically inside the workflow sandbox. The failure comes back unchanged, so a caller triages exactly what it would have without the saga.

Example ​

ts
const fulfilled = await context
  .saga()
  .step(
    () => context.activities.reserveStock(order),
    (reservation) => context.activities.releaseStock({ id: reservation.id }),
  )
  .step(
    () => context.activities.chargeCard(order),
    (charge) => context.activities.refund({ id: charge.id }),
  )
  .step(() => context.activities.ship(order))
  .run();

References ​

ACTIVITY_CANCELLED_ERROR_TAG ​

Re-exports ACTIVITY_CANCELLED_ERROR_TAG


ACTIVITY_DEFINITION_NOT_FOUND_ERROR_TAG ​

Re-exports ACTIVITY_DEFINITION_NOT_FOUND_ERROR_TAG


ACTIVITY_ERROR_TAG ​

Re-exports ACTIVITY_ERROR_TAG


ActivityInputValidationError ​

Re-exports ActivityInputValidationError


ActivityOutputValidationError ​

Re-exports ActivityOutputValidationError


AnyContractError ​

Re-exports AnyContractError


CHILD_WORKFLOW_CANCELLED_ERROR_TAG ​

Re-exports CHILD_WORKFLOW_CANCELLED_ERROR_TAG


CHILD_WORKFLOW_ERROR_TAG ​

Re-exports CHILD_WORKFLOW_ERROR_TAG


CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG ​

Re-exports CHILD_WORKFLOW_NOT_FOUND_ERROR_TAG


ContractError ​

Re-exports ContractError


ContractErrorConstructors ​

Re-exports ContractErrorConstructors


ContractErrorDataValidationError ​

Re-exports ContractErrorDataValidationError


ContractErrorOptions ​

Re-exports ContractErrorOptions


ValidationError ​

Re-exports ValidationError


WORKFLOW_CANCELLED_ERROR_TAG ​

Re-exports WORKFLOW_CANCELLED_ERROR_TAG

Released under the MIT License.