Deploy task changes
Keep accepted runs replayable while changing task code and schemas.
Start with change tasks safely to pick the right tool for your change. This page covers patches in detail. Use it when a deployment changes a task's saved steps, branch order, or schemas. You need durable storage, running maintenance, and access to run lists and event history. Upgrade package and storage formats separately using Upgrade Runlane.
Add a durable branch marker
Keep the existing path and add a unique patch ID around the changed path:
if (await context.patched('billing-tax-v2')) {
await context.step.run('charge-v2', { output: receiptSchema }, chargeWithTax)
} else {
await context.step.run('charge', { output: receiptSchema }, chargeOriginal)
}The callbacks and receiptSchema are your existing application code. Keep the old step key and its read schema unchanged. Use a new key for the new operation.
patched() first reads the run's saved boolean. If no marker exists, it chooses true only when the run's starting version equals the current worker's version. It saves either result before returning. A storage failure or lost lease rejects the call; it does not return an unsaved choice.
An unmarked run from a different version takes the old branch even if its previous handler never reached that point. A version identifies code, but cannot prove which commands a run already executed. Choosing the old branch avoids silently inserting new commands into that run's replay. A marker preserves this one decision; it does not make arbitrary side effects safe.
Deploy workers with both paths
Give each code revision a distinct immutable identity:
import { createRunlane } from '@runlane/core'
const runlane = createRunlane({
lane,
queues: queueDefinitions,
tasks,
version: 'billing-2026-10-22',
})Use your application's lane, queueDefinitions, and task catalog. Without an explicit identity, the runtime uses contractDefaults.run.version, and runs.list({ version }) cannot find those runs: only explicit versions are indexed. Set a version in production whenever replay paths or schemas change. Do not reuse a version or patch ID for different code.
A root run takes its baseline at its first start. A queued root first executed after deployment therefore takes the new worker's version. Later attempts keep the baseline. Children inherit the parent's baseline at acceptance, including raw and named batches. External triggers, schedules, manual retries, and reruns create roots with a new first-start baseline.
Workers execute registered tasks regardless of baseline. Keep both branches available on every worker that can execute retained work. Inspect started events for the baseline version and actual workerVersion.
Drain every nonterminal status
Use runs.list({ version }) or runlane runs list --version <version> to inspect started work on an old baseline. Version lists support created_at order only. Follow nextCursor even when a filtered page is empty: each page examines a bounded group of runs.
Version lists exclude all runs that have never started, including children. A child's inherited versionConstraint does not become its starting version until first start. Inspect scheduled and queued work separately. Check every nonterminal status: scheduled, queued, running, retrying, released, and cancellation_requested. Include delayed retries, time waits, child waits, signals, token waits, and cancellation finalization. An empty transport queue does not prove a drain.
Keep maintenance running. Finish work, resolve external waits, or cancel work through the normal operator API. Confirm that all affected runs are terminal before retiring the code they may replay.
Retain schemas and remove the old branch
A terminal result can still be read by a parent binding or typed operator read. Keep schemas that decode retained step results, child results, and task outputs. Do not rename old counted keys or change their call order while retained work can replay them.
Remove the old branch only when no retained work or history needs it. If old records must remain readable, retain their schemas and matching readers until retention removes them. See prune old runs for retention and child dependencies.
Lifecycle hooks are resolved from the delivering worker's current task registration. Callback code is not version-pinned. Keep a worker with the task registered until pending callbacks finish. A callback removed after discovery is shown as skipped. All producers and consumers must deploy the version 3 delivery envelope together; older messages are rejected.
Remove a task with pending hooks
Inspect runs.get(runId).hooks before removing the last worker registration. Finish pending callbacks while a worker still has the task code. Workers in a mixed fleet that lack the task acknowledge hook wakeups with hook_handler_missing; delivery recovery republishes them for a registered worker. Execution wakeups still retry when task code is missing.
Unresolved discovery and pending work without an executable registration fail after waiting unclaimed for hooks.discoveryTimeout (24 hours by default), on the next worker scan or delivery-recovery pass. The run shows a specific hooks.lastFailure reason and becomes eligible for retention cleanup. Restore the registration before that deadline when the callback is required. Removing a configured callback after discovery records it as skipped. See hook delivery and budgets.
Keep schedule ownership clear
Declared schedules stay in each process's task catalog. Removing a declaration stops only processes using the new catalog; stop older maintenance deployments before relying on removal. A process leaves armed records for declarations absent from its catalog intact, so other owners can fire them. Saved activation overrides survive deploys and apply if an ID returns. Declaration IDs cannot start with runtime_schedule_.
Runtime schedules remain in storage across deployments. Register their tasks in maintenance processes, retain schemas that accept their normalized payloads at execution, and use the schedule API to replace or delete definitions. A catalog-free process can inspect runtime definitions but cannot inspect or change declarations it does not have. See schedules.