Skip to content

@temporal-contract/worker


@temporal-contract/worker / workflow

workflow

Classes

ChildWorkflowCancelledError

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

Discriminated variant of ChildWorkflowError 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.

Extends ChildWorkflowError so existing instanceof ChildWorkflowError checks still match cancellation, while instanceof ChildWorkflowCancelledError lets call sites narrow further when they need to branch on cancellation explicitly without inspecting error.cause against a Temporal SDK class — the worker-side analogue of the client-side cause-forwarding pattern.

Extends

Constructors

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

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

Parameters
ParameterType
workflowNamestring
cause?unknown
Returns

ChildWorkflowCancelledError

Overrides

ChildWorkflowError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-ChildWorkflowError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstring-ChildWorkflowError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-ChildWorkflowError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstring-ChildWorkflowError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
workflowNamereadonlystring--packages/worker/src/errors.ts:206
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.ChildWorkflowError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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

ChildWorkflowError.captureStackTrace

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from

ChildWorkflowError.prepareStackTrace


ChildWorkflowError

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

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.

Extends

  • WorkerError

Extended by

Constructors

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

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

Parameters
ParameterType
messagestring
cause?unknown
Returns

ChildWorkflowError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

ChildWorkflowNotFoundError

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

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

Extends

  • WorkerError

Constructors

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

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

Parameters
ParameterTypeDefault value
workflowNamestringundefined
availableWorkflowsreadonly string[][]
Returns

ChildWorkflowNotFoundError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
availableWorkflowsreadonlyreadonly string[][]--packages/worker/src/errors.ts:166
cause?publicunknownundefined-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringundefined-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringundefined-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringundefined-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
workflowNamereadonlystringundefined--packages/worker/src/errors.ts:165
stackTraceLimitstaticnumberundefinedThe 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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

QueryInputValidationError

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

Error thrown when query input validation fails

Extends

  • WorkerError

Constructors

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

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

Parameters
ParameterType
queryNamestring
issuesreadonly Issue[]
Returns

QueryInputValidationError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
issuesreadonlyreadonly Issue[]--packages/worker/src/errors.ts:110
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
queryNamereadonlystring--packages/worker/src/errors.ts:109
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

QueryOutputValidationError

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

Error thrown when query output validation fails

Extends

  • WorkerError

Constructors

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

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

Parameters
ParameterType
queryNamestring
issuesreadonly Issue[]
Returns

QueryOutputValidationError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
issuesreadonlyreadonly Issue[]--packages/worker/src/errors.ts:124
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
queryNamereadonlystring--packages/worker/src/errors.ts:123
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

SignalInputValidationError

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

Error thrown when signal input validation fails

Extends

  • WorkerError

Constructors

Constructor
ts
new SignalInputValidationError(signalName, issues): SignalInputValidationError;

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

Parameters
ParameterType
signalNamestring
issuesreadonly Issue[]
Returns

SignalInputValidationError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
issuesreadonlyreadonly Issue[]--packages/worker/src/errors.ts:96
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
signalNamereadonlystring--packages/worker/src/errors.ts:95
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

UpdateInputValidationError

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

Error thrown when update input validation fails

Extends

  • WorkerError

Constructors

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

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

Parameters
ParameterType
updateNamestring
issuesreadonly Issue[]
Returns

UpdateInputValidationError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
issuesreadonlyreadonly Issue[]--packages/worker/src/errors.ts:138
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
updateNamereadonlystring--packages/worker/src/errors.ts:137
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

UpdateOutputValidationError

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

Error thrown when update output validation fails

Extends

  • WorkerError

Constructors

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

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

Parameters
ParameterType
updateNamestring
issuesreadonly Issue[]
Returns

UpdateOutputValidationError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
issuesreadonlyreadonly Issue[]--packages/worker/src/errors.ts:152
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
updateNamereadonlystring--packages/worker/src/errors.ts:151
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

WorkflowCancelledError

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

Error surfaced in the err(...) branch of a ResultAsync 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 surface as a sibling WorkflowScopeError on the same err(...) channel, so callers can use instanceof to discriminate without falling back to try/catch.

Extends

  • WorkerError

Constructors

Constructor
ts
new WorkflowCancelledError(cause?): WorkflowCancelledError;

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

Parameters
ParameterType
cause?unknown
Returns

WorkflowCancelledError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

WorkflowInputValidationError

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

Error thrown when workflow input validation fails

Extends

  • WorkerError

Constructors

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

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

Parameters
ParameterType
workflowNamestring
issuesreadonly Issue[]
Returns

WorkflowInputValidationError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
issuesreadonlyreadonly Issue[]--packages/worker/src/errors.ts:68
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
workflowNamereadonlystring--packages/worker/src/errors.ts:67
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

WorkflowOutputValidationError

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

Error thrown when workflow output validation fails

Extends

  • WorkerError

Constructors

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

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

Parameters
ParameterType
workflowNamestring
issuesreadonly Issue[]
Returns

WorkflowOutputValidationError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
issuesreadonlyreadonly Issue[]--packages/worker/src/errors.ts:82
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
workflowNamereadonlystring--packages/worker/src/errors.ts:81
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

WorkflowScopeError

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

Error surfaced in the err(...) branch of a ResultAsync when the function passed to cancellableScope / nonCancellableScope throws a non-cancellation error.

The original error is preserved on cause so call sites can introspect it without losing identity:

Example

ts
const result = await context.cancellableScope(async () => {
  return await context.activities.processStep(args);
});

if (result.isErr()) {
  if (result.error instanceof WorkflowCancelledError) {
    // graceful cancellation
  } else if (result.error instanceof WorkflowScopeError) {
    // domain error — `result.error.cause` is the original throwable
  }
}

Introduced so the scope helpers route every failure through neverthrow's railway. Previously, non-cancellation errors were re-thrown out of the helper, which became a ResultAsync rejection (new ResultAsync(promise) does not catch) — they leaked as unhandled rejections rather than surfacing on the typed error channel callers actually inspect.

Extends

  • WorkerError

Constructors

Constructor
ts
new WorkflowScopeError(cause): WorkflowScopeError;

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

Parameters
ParameterType
causeunknown
Returns

WorkflowScopeError

Overrides
ts
WorkerError.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
cause?publicunknown-WorkerError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstring-WorkerError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstring-WorkerError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstring-WorkerError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
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.WorkerError.stackTraceLimitnode_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:68

Methods

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

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:52

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
ts
WorkerError.captureStackTrace
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@24.12.2/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

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

Inherited from
ts
WorkerError.prepareStackTrace

Functions

declareWorkflow()

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

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

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';

export const processOrder = declareWorkflow({
  workflowName: 'processOrder',
  contract: myContract,
  activityOptions: {
    startToCloseTimeout: '1 minute',
  },
  // 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.
  activityOptionsByName: {
    chargePayment: {
      startToCloseTimeout: '5 minutes',
      retry: { maximumAttempts: 5 },
    },
  },
  implementation: async (context, args) => {
    // context.activities: typed activities (workflow + global)
    // context.info: WorkflowInfo

    const inventory = await context.activities.validateInventory({
      orderId: args.orderId,
    });

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

    const payment = await context.activities.chargePayment({
      customerId: args.customerId,
      amount: 100,
    });

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

Then in your worker setup:

ts
// worker.ts
import { createWorker } from '@temporal-contract/worker/worker';
import { activities } from './activities';
import myContract from './contract';

const worker = await createWorker({
  contract: myContract,
  connection,
  workflowsPath: workflowsPathFromURL(import.meta.url, './workflows.js'),
  activities,
});

References

ActivityInputValidationError

Re-exports ActivityInputValidationError


ActivityOutputValidationError

Re-exports ActivityOutputValidationError

Released under the MIT License.