Errors
Construct Runlane errors, control retries, and read stored failures.
Import ErrorCode and RunlaneError from @runlane/core.
Local development storage errors
Without runlane dev, the first createLocalLane() storage operation rejects with storage_unavailable. The message names the searched config path:
runlane dev is not running for <config path>. Start it with "runlane dev", then retry. In tests, use createTestLane().The failed trigger saves no run. Start dev for that config and retry in the same app process. If dev is starting or stopping, wait for it to finish and retry. A disconnected lane never falls back to app memory. Restarting dev clears its runs; later operations reconnect to fresh memory.
If dev serves a different lane name than the app, operations reject with configuration_invalid and name both lanes. Use the same name in the app and the config's runtime.
For tests without dev, use createTestLane(). Same-name test handles must use the same clock function; conflicting clocks reject with configuration_invalid.
Construct an error
Use RunlaneError when a task needs to save a public reason or state whether a failure can be retried:
import { ErrorCode, RunlaneError } from '@runlane/core'
throw new RunlaneError({
code: ErrorCode.TaskFailed,
message: 'The account no longer exists.',
retryable: false,
meta: { reason: 'account_deleted' },
})The constructor accepts RunlaneErrorOptions:
| Field | Type and default |
|---|---|
code | Required ErrorCode. |
message | Optional string. Defaults to the code. |
retryable | Optional boolean. Defaults to false. |
cause | Optional original thrown value, kept for internal diagnosis. |
meta | Optional JsonObject with safe, structured context. |
The instance extends Error and exposes these fields. Use error instanceof RunlaneError before reading them. Every instance carries Symbol.for('runlane.error'). The base-class check works across package copies. Subclasses keep normal prototype checks, so sibling subclasses remain distinct. Match error.code, not message text. If you catch another kind of error, treat it as an unexpected application or dependency failure.
Realtime and React use the same class and ErrorCode values. Import them from @runlane/realtime or @runlane/realtime/client. A resume checkpoint is in error.meta?.cursor. Unexpected reader failures use internal_error and preserve the original value as cause.
Task handlers and token callbacks share one retry rule: a plain Error means a temporary failure. Runlane retries it while a budget remains. A RunlaneError stops retries unless retryable: true.
Thrown errors and stored failures
Public operations such as trigger() reject when setup, validation, or storage fails before a confirmed commit. After a confirmed commit, a delivery failure returns success with deliveryError; do not repeat the saved change. See saved changes and delivery errors.
Handler failures are normally saved on the run. runNow() executes one attempt and returns a RunRecord; a failed handler does not normally make that call reject. Check the returned run's status and failure, or read the run later through runlane.runs.get().
A stored RunFailure keeps the thrown error's name, message, and stack. Plain errors use code: task_failed and the task's retry policy. RunlaneError also keeps its code, retryable, and meta. Strings keep their text; other thrown values use safe inspection that does not call custom inspectors or getters. Non-error throws receive an Error identity and a stack captured when Runlane handles them.
Messages and names are capped at contractDefaults.run.failureMessageMaxLength UTF-16 code units. Stacks use contractDefaults.run.failureStackMaxLength. Runlane replaces U+0000 (NUL) in names, messages, and stacks with U+FFFD before applying length limits so every lane can store failures. Invalid Unicode and NUL in failure metadata values and keys are also replaced with U+FFFD; if replacement produces duplicate keys, the last key wins. It also replaces unmatched UTF-16 halves, including those left by truncation, with U+FFFD. Empty error messages remain empty. Causes are not copied. Older records and system-generated failures may omit name and stack. See defaults for current limits.
Each run.retry_scheduled and run.failed event stores that attempt's failure through the storage driver. Server-side operators and CLI JSON can read the stack. Browser snapshots and status deltas expose only name, code, message, and retryable, with the Output permission. They never expose stacks or failure metadata. Keep secrets and raw provider responses out of thrown messages: messages are stored and may be shown to those users.
Invalid options passed to task-context waits or steps throw configuration_invalid. For unrecognized option names, meta.unsupportedOptions lists those names. If the handler lets the error escape, that metadata is saved with the failure.
Updating metadata or tags on a terminal run rejects with validation_failed.
Shared not-found messages
notFoundErrorMessages from @runlane/contracts owns the public text for required missing resources. Read its fields when constructing provider or operator errors:
| Field | Meaning |
|---|---|
run | A required run was not found. |
task | The task is not registered in this runtime. |
waitToken | A required wait token was not found. |
Match the error code when handling failures; the message is for readers. Optional reads can return undefined instead, as described in runs and waits.
Outcomes that exceed storage limits
If storage rejects a handler's output, release reason or metadata, or failure metadata for size, Runlane saves a non-retryable storage_limit_exceeded failure instead. This also applies when that failure would otherwise schedule a retry. Its message is "Task outcome is too large to store. Store large values outside Runlane and save a reference."
failure.meta contains only actual, limit, and outcome. The measurements use the same unit, bytes or records. The outcome is success, release, or failed; failed includes a rejected retry-scheduled failure. The oversized value is not saved. Other runs sharing a persistence batch can still succeed, and a waiting parent receives the child's stored failure through join().
If the replacement failure cannot be saved either, the storage error still rejects the execution call. Other persistence errors keep their usual handling.
Retry decisions
| Handler result | Automatic retry behavior |
|---|---|
Ordinary thrown Error, with a task retry policy | Retries while run.counters.retries is below the policy's maxRetries. |
RunlaneError with retryable: true | Retryable only if the task also has a retry policy and budget remains. |
RunlaneError with retryable: false or no retryable field | Ends as failed without automatic retry. |
| Any failure with no task retry policy | No automatic retry. |
| Crash allowance exceeded | Records task_interrupted with retryable: false. The run fails even if failure retries remain. |
| Attempt deadline expires | Records task_timed_out. Retries if the task policy allows another attempt; otherwise ends as failed. |
| Awaited release or pending wait | Ends the attempt without recording a failure, spending retry budget, or increasing retry backoff. |
Mark a failure retryable only if repeating the work can help. The retry guide shows both temporary and permanent failures in one task.
Error codes
These members belong to ErrorCode. Their stored values use snake case.
| Member | Stored value | Meaning |
|---|---|---|
AccessDenied | access_denied | The caller or scoped token cannot read the run. |
Disconnected | disconnected | A realtime connection failed or exhausted its retry budget. |
EventTooLarge | event_too_large | One serialized realtime event exceeds the byte limit. |
WireInvalid | wire_invalid | A realtime response does not match the wire contract. |
AdapterContractViolation | adapter_contract_violation | An adapter returned data or behavior outside its contract. |
CapabilityUnsupported | capability_unsupported | The configured lane or provider does not support the operation. |
ConfigurationInvalid | configuration_invalid | A definition or option is invalid. |
InternalError | internal_error | An internal operation failed. |
InvariantViolation | invariant_violation | Stored or runtime state violates a required rule. |
OperationCancelled | operation_cancelled | An operation was cancelled. |
ObservationExportFailed | observation_export_failed | Exporting observations failed. |
RunIdConflict | run_id_conflict | A requested run ID conflicts with another task, an idempotency owner, or an existing linked-run ID. Retryable only while a pruned run's ID awaits cleanup. See run ID conflicts. |
RunNotFound | run_not_found | An operation requires a run that does not exist. A plain runs.get() returns undefined instead. |
LogLimitExceeded | log_limit_exceeded | An individual log body exceeds logs.maxEntryBytes. Run-wide quotas truncate logs instead of failing execution. |
ScheduleConflict | schedule_conflict | A schedule deduplication key belongs to a different definition; use update. |
QueuePaused | queue_paused | runNow() refused a paused queue. Nothing was saved. Not retryable until the queue is resumed; call trigger() to queue the work instead. Metadata contains queue and taskId. A delivery Retry for a paused queue uses the same code with retryable: true; the provider keeps redelivering on its normal backoff until the queue resumes. |
QueueAtCapacity | queue_at_capacity | runNow() refused a full total or per-key pool. Nothing was saved. Retryable; retry later or call trigger() to queue the work. Metadata contains queue and taskId. A delivery Retry for a full queue uses the same code. |
StorageConflict | storage_conflict | A concurrent write or ownership claim conflicted. |
StorageLimitExceeded | storage_limit_exceeded | An operation is larger than storage can hold or commit atomically. meta.actual and meta.limit report the measured size and the limit in the same unit. Not retryable. |
StorageUnavailable | storage_unavailable | Storage could not serve the operation. |
TaskFailed | task_failed | The task handler failed. |
TaskInterrupted | task_interrupted | Worker shutdown abort reasons from createWorkerShutdownError() are retryable. An execution or delivery signal abort before the handler error makes it an interruption, whatever the abort reason. See Stop crash loops for the interruption allowance. Exceeding a finite allowance records a non-retryable failure; no new attempt starts. |
TaskNotFound | task_not_found | The runtime cannot find the task definition. |
TaskOutputInvalid | task_output_invalid | Task output does not match its schema or storage format. |
TaskTimedOut | task_timed_out | An attempt exceeded its time limit, or a joined run missed its first-start deadline. |
TransportPublishFailed | transport_publish_failed | Publishing a delivery request failed. |
TransportUnavailable | transport_unavailable | The delivery service is unavailable. |
ValidationFailed | validation_failed | A payload or other operation input failed validation. |
WaitTimedOut | wait_timed_out | One signal wait or token wait window reached its timeout. A token window leaves the token pending. |
WaitTokenExpired | wait_token_expired | The token reached its own creation deadline before completion. |
WaitTokenNotFound | wait_token_not_found | An operation requires a missing wait token. A plain token read returns undefined instead. |
WaitTokenOutputInvalid | wait_token_output_invalid | A completed token's output does not match the requested schema. |
Use the error's retryable field and the operation's state to decide what to do next. An error code alone is not a promise that retrying is safe.
Run ID conflicts
A raw trigger with an existing runId returns that run when it belongs to the same task, in any status. run_id_conflict means the requested run ID can't be used:
- The ID belongs to a run of another task.
- The call's idempotency key, from the call or the task, belongs to a different run.
- A named child step requests an ID that a stored run already has. Named steps don't reuse runs by ID. The exception is a step whose idempotency key already points to that same run, which returns it.
runs.retry()orruns.rerun()requests an ID that is already taken.- The ID belongs to a pruned run that cleanup hasn't removed yet.
Retrying the same call can't fix the first four cases, so choose the intended run identity. The pruned case is retryable: the ID is free again after cleanup.
Schedule conflicts
schedule_conflict means a runtime schedule's environment-scoped deduplication key belongs to a different definition. Identical keyed creates return the existing schedule. Replace a definition through schedules.update(); externalId is a nonunique label. Invalid timing, zones, and declared definition mutations use configuration_invalid.
Log limits
log_limit_exceeded means an individual log body exceeds logs.maxEntryBytes. This rejection throws at a context.logger call. Console capture reports the rejected record through runtime telemetry without throwing into task code. Run-wide entry and byte quotas save one truncation marker and drop later entries without failing an attempt or hook.
Stream and cursor errors
| Stream and cursor code | Stored value | Meaning |
|---|---|---|
StreamLimitExceeded | stream_limit_exceeded | A normalized chunk, name count, run byte count, or record count exceeded its stream quota. |
RunCursorInvalid | run_cursor_invalid | A source cursor is malformed or belongs to another reader, environment, run, or retained instance, or exceeds a source tail. |