Type Alias: EngineOptions {#type-alias-engineoptions}
EngineOptions =
object
Configuration options for createEngine.
Properties {#properties}
concurrency? {#concurrency}
optionalconcurrency:number
Maximum number of runs executed concurrently.
Default Value {#concurrency-default-value}
10
handlerTimeoutMs? {#handlertimeoutms}
optionalhandlerTimeoutMs:number
Timeout in milliseconds for each handler execution.
Default Value {#handlertimeoutms-default-value}
30000
heartbeatIntervalMs? {#heartbeatintervalms}
optionalheartbeatIntervalMs:number
Heartbeat interval in milliseconds (defaults to leaseTimeoutMs / 3). Must be strictly less than leaseTimeoutMs, otherwise the lease expires before the first heartbeat.
Throws {#heartbeatintervalms-throws}
EngineError with code ErrorCode.INVALID_CONFIG if >= leaseTimeoutMs.
leaseTimeoutMs? {#leasetimeoutms}
optionalleaseTimeoutMs:number
Lease duration in milliseconds for crash recovery.
Default Value {#leasetimeoutms-default-value}
30000
maxChainDepth? {#maxchaindepth}
optionalmaxChainDepth:number
Maximum depth of chained event chains.
Default Value {#maxchaindepth-default-value}
10
maxPayloadBytes? {#maxpayloadbytes}
optionalmaxPayloadBytes:number
Maximum payload size in bytes.
Default Value {#maxpayloadbytes-default-value}
1048576 (1 MB)
onDead()? {#ondead}
optionalonDead: (run,error) =>void
Called when a run exhausts its retry budget and is marked with dead-letter status.
Parameters {#ondead-parameters}
run {#ondead-run}
error {#ondead-error}
string
Returns {#ondead-returns}
void
onEvent()? {#onevent}
optionalonEvent: (event) =>void
Unified lifecycle event callback. Fires synchronously for every engine event.
Must not throw, exceptions are caught and reported to onInternalError
but deliberately not re-emitted as internal:error to prevent recursion.
Parameters {#onevent-parameters}
event {#onevent-event}
Returns {#onevent-returns}
void
Example {#onevent-example}
const engine = createEngine({
onEvent(event) {
if (event.type === 'run:complete') {
console.log(`${event.run.processName} completed in ${event.durationMs}ms`)
}
},
})
onInternalError()? {#oninternalerror}
optionalonInternalError: (error,context) =>void
Called when an internal error is caught that would otherwise be silently swallowed.
The context string identifies the error site (e.g. 'fillSlots', 'heartbeat', 'onRunStart').
Parameters {#oninternalerror-parameters}
error {#oninternalerror-error}
unknown
context {#oninternalerror-context}
string
Returns {#oninternalerror-returns}
void
onRetry()? {#onretry}
optionalonRetry: (run,error,attempt) =>void
Called when a run is retried after failure.
Parameters {#onretry-parameters}
run {#onretry-run}
error {#onretry-error}
string
attempt {#onretry-attempt}
number
Returns {#onretry-returns}
void
onRunError()? {#onrunerror}
optionalonRunError: (run,error) =>void
Called when a run transitions to errored.
Parameters {#onrunerror-parameters}
run {#onrunerror-run}
error {#onrunerror-error}
string
Returns {#onrunerror-returns}
void
onRunFinish()? {#onrunfinish}
optionalonRunFinish: (run) =>void
Called when a run finishes, regardless of outcome (completed or errored).
Parameters {#onrunfinish-parameters}
run {#onrunfinish-run}
Returns {#onrunfinish-returns}
void
onRunStart()? {#onrunstart}
optionalonRunStart: (run) =>void
Called when a run transitions to running.
Parameters {#onrunstart-parameters}
run {#onrunstart-run}
Returns {#onrunstart-returns}
void
retention? {#retention}
optionalretention:number|string
Automatically prune completed non-deferred runs older than this duration.
Accepts either milliseconds or a compact string like '30d', '12h', '15m', or '500ms'.
Effect records for deleted runs are pruned alongside them.
retry? {#retry}
optionalretry:RetryPolicy
Default retry policy applied to all processes without an explicit policy.
server? {#server}
optionalserver:DevServerOptions
Start a dev dashboard HTTP server. The server holds the Node.js event loop open until stopped.
store? {#store}
optionalstore:"memory"| {path:string;type:"sqlite"; }
Storage backend: 'memory' (default) or SQLite with a file path.