Skip to Content

Upgrading

Breaking and behaviour changes in this release, and what to change in your application

This page lists every change since the previous release that can break your build, change what your application sees, or needs an action during the deploy. Each entry says what changed, why, and what you must do. Read it from top to bottom before you upgrade; the checklist at the end sums it up.

Dependencies

Peer dependencies and Node.js version

What changed. drizzle-orm, postgres and @electric-sql/pglite are now declared peer dependencies, and Duron depends on @opentelemetry/api only (also a peer). Duron no longer installs an OpenTelemetry SDK.

PackageRangeRequired
drizzle-orm1.0.0-rc.6 || ^1.0.0yes
@opentelemetry/api^1.9.0yes
postgres^4.1.1for duron/adapters/postgres
@electric-sql/pglite^0.5.17 || ^0.6.0for duron/adapters/pglite

drizzle-orm 1.0 release candidates are ESM-only, so on Node.js Duron needs ^20.19.0 or >=22.12.0 (now in engines).

Why. Your application and Duron must share one copy of Drizzle, of the database driver and of the OpenTelemetry API. postgres.js 3.x has two connection bugs that 4.x fixes (an uncaught exception on a lost connection, and a session left open after stop()); see Claim Admission.

What to do. Install the exact drizzle-orm version: the peer range does not accept later release candidates (such as drizzle-orm@rc once rc.7 ships).

bun add duron drizzle-orm@1.0.0-rc.6 @opentelemetry/api
bun add postgres            # PostgreSQL adapter
bun add @electric-sql/pglite@0.6   # PGlite adapter

See Getting Started.

PGlite data directories

What changed. The PGlite adapter now needs PGlite 0.5.17 or later 0.5.x (PostgreSQL 18) or 0.6 (PostgreSQL 19). The previous release was tested with PGlite 0.3 (PostgreSQL 17).

What to do. An in-memory PGlite database needs nothing. A persistent PGlite data directory opens only with the PostgreSQL major version that created it. For a directory created by PGlite 0.3, dump the data with that version and restore it into a new directory with 0.5 or 0.6. A directory created by 0.5 needs PGlite 0.5 or the same dump and restore for 0.6.

Telemetry

What changed. telemetry: { traceExporter, serviceName, batchDelayMs } is replaced by telemetry: { tracerProvider }. Your application creates the OpenTelemetry tracer provider (with its Resource, span processors and exporters) and passes it to Duron. A telemetry object without a valid tracerProvider, or with a removed option, makes the Client constructor throw a TypeError. Without the telemetry option Duron uses a no-op tracer: it does not fall back to the global tracer provider.

Why. A library should not bring its own copy of the OpenTelemetry SDK. Your application chooses the SDK version, the service name and the exporters.

What to do.

Before:

const client = duron({
  database,
  actions,
  telemetry: { traceExporter: new OTLPTraceExporter(), serviceName: 'my-service' },
})

After:

import { resourceFromAttributes } from '@opentelemetry/resources'
import { BatchSpanProcessor, TracerProvider } from '@opentelemetry/sdk-trace'

const tracerProvider = new TracerProvider({
  resource: resourceFromAttributes({ 'service.name': 'my-service' }),
  spanProcessors: [new BatchSpanProcessor({ exporter: new OTLPTraceExporter() })],
})

const client = duron({ database, actions, telemetry: { tracerProvider } })

// On shutdown
await client.stop()
await tracerProvider.shutdown()

ctx.telemetry.getTracer(name) (in handlers and steps) used to ignore name and return Duron's tracer. It now returns tracerProvider.getTracer(name), so custom spans created with it carry the instrumentation scope name instead of duron; update trace queries that filter on the scope. ctx.telemetry.startSpan() still uses Duron's tracer.

If you start a NodeSDK, pass its provider explicitly (telemetry: { tracerProvider: trace.getTracerProvider() }), or Duron's spans disappear. See Migration from traceExporter.

The TelemetryContext type exported by duron/client is now the type of ctx.telemetry (the one duron exports): getActiveSpan() returns Span | undefined, and startSpan() is included. Code that typed ctx.telemetry with the old duron/client type may need ?. on getActiveSpan().

Client lifecycle

One adapter instance per Client

What changed. Creating a second Client with an adapter that another Client uses, or used and stopped, throws a TypeError.

Why. Sharing never worked: the Clients shared one client ID and one liveness row, each one's recovery could requeue the other's running jobs, and stopping one stopped the other.

What to do. Create one adapter per Client.

// Before: one adapter shared by two Clients
const database = postgresAdapter({ connection })
const api = duron({ database, syncPattern: false })
const worker = duron({ database, actions })

// After: one adapter each
const api = duron({ database: postgresAdapter({ connection }), syncPattern: false })
const worker = duron({ database: postgresAdapter({ connection }), actions })

stop() is final and can reject

What changed.

  • The lifecycle belongs to the adapter. After stop(), start() resolves false and every other Client method rejects (Lifecycle is not accepting work). A stopped adapter cannot start again.
  • stop() rejects when a shutdown phase does not finish within its budget or a cleanup step fails (with that error, or an AggregateError for several failures). Before, it could hang.

Why. A stopped instance released its liveness row and connections; reusing it raced with that cleanup.

What to do. To restart, create a new adapter and a new Client. Await stop() and handle its rejection, for example in your signal handler:

process.on('SIGTERM', async () => {
  try {
    await client.stop()
  } catch (error) {
    logger.error({ error }, 'Duron did not stop cleanly')
  } finally {
    process.exit(0)
  }
})

See How it works: phases and budgets.

Graceful stop() returns unfinished jobs to the queue

What changed. stop() aborts the running handlers as before, but a job that does not finish is now returned to the queue (status created, no owner) instead of being cancelled. Claimed jobs that did not start are returned too (before, they stayed active until recovery). A handler that still resolves after the abort completes its job, a job that already failed stays failed, and an explicit cancelJob() still cancels. The next run reuses the completed steps.

Why. A deploy or a scale-down should not cancel work: another worker can finish it.

What to do. Make handlers safe to run again after a restart (steps that already completed are not run again; a step that was running is). For a job that must not run again, call cancelJob() before stop(). To give handlers more time to finish, raise the new shutdownTimeout option.

const client = duron({
  database,
  actions,
  shutdownTimeout: 30_000, // default 5000: budget of each stop phase
})

See How it works: releasing unfinished jobs.

Startup needs a working heartbeat

What changed. The heartbeat (the Client's liveness row in the clients table) is written with the database clock (now()) instead of the application clock, and its errors are no longer ignored. start() waits for the first heartbeat, so start() (and the first method call that starts the Client) rejects when it fails. Later heartbeat failures are logged and retried.

Why. A heartbeat that silently failed let other workers think this worker was dead and requeue its running jobs. The database clock removes the clock offset between workers from the liveness check.

What to do. Make sure the clients table exists (export clientsTable if you manage Duron's tables with your own migrations) and that the worker's database role can INSERT and UPDATE it. See Heartbeat clock and failure limits.

New option shutdownTimeout

What changed. The budget of each phase of stop() was a fixed 5 seconds. It is now the shutdownTimeout option (default 5000). The stopping Client keeps its heartbeat while it drains, so shutdownTimeout can be longer than heartbeatTimeout.

What to do. Nothing, unless your handlers need more time. Keep your orchestrator's grace period (for example Kubernetes' terminationGracePeriodSeconds) above four budgets.

Workers and recovery

Worker IDs must be unique per running process

What changed. Recovery rescues the jobs of this Client's own id that this Client does not hold (for example, jobs left active by an earlier process with the same id). Before, it requeued every job of its own id, including jobs it was running, so they ran twice.

Why. A restarted worker with a stable id now picks up its own leftovers at once, without waiting for its old heartbeat to go stale.

What to do. Give each running process its own id. Two running processes with the same id requeue each other's running jobs. worker-${process.pid} is not unique in containers, where every worker is usually PID 1.

// Before
id: `worker-${process.pid}`

// After (omitting `id` also gives a random UUID)
id: `worker-${crypto.randomUUID()}`

See Worker IDs.

Direct adapter calls

What changed.

  • A job claimed with a direct client.database.fetch() carries the Client's ID but is not held by the Client, so the Client's next startup or periodic recovery requeues it.
  • A direct client.database.recoverJobs() call on an adapter that a Client uses skips the Client's own ID (it cannot know which of those jobs are running).

What to do. Use client.fetch() to claim jobs manually. To recover the jobs of other workers by hand, client.database.recoverJobs({ checksums }) still works. See Job Recovery.

syncPattern: 'push' also runs periodic discovery

What changed. 'push' now also checks for work every pullInterval, like 'hybrid'. Before, it relied on notifications only.

Why. Notifications are hints: a lost notification, a job requeued by recovery or a freed group slot left work unclaimed until the next notification.

What to do. Nothing. Use syncPattern: false for a Client that must not claim jobs.

client.fetch()

What changed. Manual fetch() calls are served one at a time together with automatic discovery, return after their claim (not after the handlers), and reject when the Client did not start.

What to do. Nothing in most applications. Handle the rejection of a fetch() that you do not await. See fetch.

Waiting for results

What changed. runActionAndWait() rejected with Job not found when its first read of the job failed or timed out, or when the Client stopped. It now rejects with:

  • WaitReadTimeoutError when that read does not finish within the new waitReadTimeout option (default 5000 ms);
  • WaitReadFailedError when that read fails (the read error is its cause);
  • Lifecycle is not accepting work when the Client stops while the call waits (or Client is not accepting work when the stop begins right after the job was created, before the wait starts).

Both new errors are exported from duron. A waitForJob() call made after stop() began rejects with Lifecycle is not accepting work; a wait that is pending when stop() begins still resolves null.

Why. Job not found was wrong: the job exists and may still run.

What to do. If you matched on Job not found, also handle the new errors:

import { WaitReadFailedError, WaitReadTimeoutError } from 'duron'

try {
  await client.runActionAndWait('sendEmail', input)
} catch (error) {
  if (error instanceof WaitReadTimeoutError || error instanceof WaitReadFailedError) {
    // The job may still run: look it up later with error.metadata.jobId
  }
}

See runActionAndWait.

Job listing

What changed.

  • getJobs({ sort: [] }) (and GET /jobs without a valid sort) uses the default sort, startedAt descending.
  • Jobs are sorted across active and archive storage before paging, with a final tie-break on the job ID, so every job appears on exactly one page.
  • Text sorts (status, actionName, description) use byte order (COLLATE "C"), not the database locale. Dates sort at their stored microsecond precision. duration sorts by its numeric value.
  • getJobSteps({ search, updatedAfter }) applies updatedAfter to name matches too.

Why. Pages could repeat or skip jobs, and sorts by status or action on large tables took seconds.

What to do. If you show sorted lists, check that the new order suits you (for example, uppercase letters now sort before lowercase ones). See getJobs.

Database migrations

The adapter applies Duron's new migrations on startup unless migrateOnStart is false (see below). Two of the new migrations need attention on existing databases; the action concurrency column (20261203025959) needs nothing.

The Client's migrateOnStart applies

What changed. duron({ migrateOnStart: false }) now turns off the migrations at start. Before, only the adapter option (postgresAdapter({ migrateOnStart })) did, and the Client option had no effect. Migrations run at start only when neither option is false.

What to do. If you set migrateOnStart: false on the Client but relied on the adapter to migrate, remove it from the Client. See migrateOnStart.

A custom schema needs your own migrations

What changed. The built-in migrations are only for the default duron schema. With an adapter schema other than duron, start() now fails fast, before it changes the database, when the built-in migrations would run at start (migrateOnStart is not false and there is no migrationsFolder). The error names the schema and points to Integrating Duron Schema. Before, the built-in migrations created a separate duron schema that the adapter did not use.

What to do. If you use another schema, include Duron's tables in your own Drizzle schema with createSchema('<name>'), generate their migrations with drizzle-kit, and set migrateOnStart: false (on the adapter or the Client). If an old version created an unused duron schema next to yours, you can drop it. Nothing changes for the duron schema.

The adapter option migrationsFolder applies

What changed. The adapters accepted a migrationsFolder option but ignored it. It now replaces the built-in migrations: the adapter applies that folder's migrations at start and records them in duron.migrations, like the built-in ones.

What to do. If you pass migrationsFolder, check that it points to migrations that create every Duron table, or remove it to use the built-in migrations. See PostgreSQL Adapter.

Job listing indexes (20261130153037)

What changed. Six indexes on jobs_active and jobs_archive serve the job listing sorts.

What to do. Nothing for small tables. On large tables the migration blocks writes to both job tables while it builds the indexes. Build them first with CREATE INDEX CONCURRENTLY (the migration then builds nothing), or upgrade in a maintenance window. See Upgrading to the job listing indexes.

Claim lock table (20261202120334)

What changed. An empty claim_lock table. Every claim locks it, so the claims of all workers on a schema run one at a time and lock only the jobs they take.

What to do. If your workers connect with a different database role than the one that runs the migrations, grant the new table to the worker role before you start upgraded workers, or every claim fails with SQLSTATE 42501:

GRANT UPDATE ON "duron"."claim_lock" TO <worker_role>;

Old and new workers can run together during a rolling upgrade. See Upgrading to the claim lock.

Action concurrency applies (20261203025959)

What changed. The action option concurrency was accepted (default 100) but not applied. It is now the maximum number of running jobs of the action across all workers, and it has no default: an action without it has no limit of its own, as before. The migration adds the nullable column action_concurrency_limit to jobs_active and jobs_archive (no table rewrite). Each job stores its action's limit, and the claim admits a job only when both its group and its action have a free slot. Jobs also have the new field actionConcurrencyLimit.

What to do. If an action sets concurrency, check the value: it now caps that action's running jobs in the whole fleet. Remove it to keep the previous behaviour. During a rolling upgrade, the limit holds only once every worker runs the new version: older workers do not apply it in their claims, and the jobs they create (or retry) have no action limit. The claim takes the limit of the action's latest unexpired job, so a job created by an old worker lifts the limit for the whole action, also on upgraded workers, until a newer job of that action is created by an upgraded worker.

Locked migrations

What changed. Each instance runs its migrations in one READ COMMITTED transaction behind an advisory lock, so instances that start at the same time migrate one at a time instead of failing.

What to do. Nothing. See Migrations.

Own Drizzle migrations

If you manage Duron's tables with your own Drizzle migrations, export claimLockTable from createSchema() and generate a migration: the generated SQL contains the new indexes, the claim_lock table and the action_concurrency_limit columns. See Integrating Duron Schema.

Archive retention and timestamps

Prune lock key per schema

What changed. The scheduled prune (the adapters' pruneArchive option) used the advisory lock key 42 for every schema. The key is now derived from the schema name, so Duron schemas in one database no longer block each other. On PostgreSQL the lock is held on a dedicated connection, so an adapter with pruneArchive opens one more connection; a lost lock connection (a failover or an idle timeout) is replaced by a later tick.

What to do. Count the extra connection if your database limits connections. During a rolling upgrade an old and a new worker can prune the same schema at the same time. This is harmless (at worst one pass fails with a deadlock error and the next tick retries) and ends when every worker is upgraded. See PostgreSQL lock session and key.

finishedAt from the database clock

What changed. A job's finishedAt and the archived updatedAt now come from the database clock (now()) instead of the application clock, like the claim and step times. The heartbeat changed too (see Startup needs a working heartbeat).

What to do. Nothing, unless your application and database clocks differ: the cutoff of a duration in pruneArchive({ olderThan: '30d' }) is still computed from the application clock.

Server

Only access tokens authorize API requests

What changed. With login, the protected endpoints of createServer accepted any token signed with jwtSecret, including a refresh token. They now accept only an access token, and a refresh token gets 401. POST /refresh still accepts only a refresh token. The tokens are verified as HS256 only.

Why. A leaked refresh token (valid 7 days by default) worked as a bearer token for every endpoint.

What to do. Nothing if you use the dashboard or send the access token. A client that sends the refresh token as a bearer token must send the access token and call POST /refresh when it expires. See Authentication.

Dashboard

React is a peer dependency

What changed. duron-dashboard declares react and react-dom as optional peer dependencies (^19.0.0) instead of dependencies (^19.3.1). The DuronDashboard component uses your application's React, so an application on React 19.0 to 19.2 no longer gets a second copy of React (an "invalid hook call" error).

What to do. If you render <DuronDashboard>, install react and react-dom 19 in your application (optional peers are not installed for you). getHTML bundles its own React and needs nothing.

getHTML uses the options of each call

What changed. getHTML cached the page of its first call, so later calls with other options got the first page. It now caches only the bundled assets and builds the page with the options of each call. The embedded options are escaped, so a value cannot close the script tag.

What to do. Nothing.

Custom adapters

If you extend Adapter (or the PostgreSQL or PGlite adapter), review these changes. Details are in Custom Adapters.

  • _releaseJob(options) (new, optional): a graceful stop() returns unfinished jobs through it. The default releases nothing: those jobs stay active until recovery requeues them, and the Client logs a warning for each one. Before, stop() cancelled them.
  • _finishesStepsWithJob (new protected getter, default false): return true once your _completeJob and _failJob write options.steps in the transaction that ends the job.
  • _heldJobIds(options) (new protected helper): tells a custom _recoverJobs which jobs of the adapter's own ID its Client holds, so that it leaves them alone.
  • clientMigrateOnStart (new protected getter, set by the Client with setMigrateOnStart()): an adapter that migrates in _start() must skip its migrations when it is false, or the Client's migrateOnStart: false has no effect on it.
  • _transaction(work, config?) (PostgreSQL and PGlite subclasses): open your own transactions with it instead of this.db.transaction(), so that a transaction that ends after stop() rolls back.
  • Locking: the claim lock, the row locks of cancel/complete/fail and recovery's per-phase locks cover only the built-in methods. An override that does not delegate to the built-in method does not take part.

Behaviour fixes that change results

These are fixes, not breaking changes, but stored data or results can differ from the previous version:

  • A time travel that returns false no longer leaves the job in active storage, no longer resets steps of other jobs, and keeps earlier steps that have the same timestamp as the target. Jobs that an older version left stranded in active storage after a failed time travel stay there (listed, but not retryable or prunable): delete them by hand.
  • Archived job rows keep exact timestamps (microseconds) and full JSON number precision.
  • When a job fails, its steps' final statuses are written before the job is archived.
  • A job cancelled after its claim but before its handler started no longer runs.
  • Group concurrency limits hold across workers, and bursts of new jobs are claimed at once instead of one batch per pullInterval.

Checklist

  1. Install the peer dependencies (drizzle-orm@1.0.0-rc.6, @opentelemetry/api, postgres 4 or PGlite 0.5.17+/0.6) on Node.js ^20.19.0 or >=22.12.0.
  2. Replace telemetry: { traceExporter, ... } with telemetry: { tracerProvider }.
  3. Use one adapter instance per Client, a unique id per running process, and a new adapter and Client to restart.
  4. Await stop() and handle its rejection; make handlers safe to run again after a stop, or cancel jobs that must not; set shutdownTimeout if needed.
  5. Handle WaitReadTimeoutError and WaitReadFailedError where you matched Job not found.
  6. On large job tables, pre-build the listing indexes. With a separate worker role, grant UPDATE on claim_lock.
  7. Custom adapters: implement _releaseJob, and review _finishesStepsWithJob, _heldJobIds and _transaction.
  8. Check the actions that set concurrency: it now caps their running jobs across all workers.
  9. If you set migrateOnStart: false on the Client, check that you run the migrations yourself. API clients must send the access token, not the refresh token.
  10. With an adapter schema other than duron, manage Duron's tables with your own migrations and set migrateOnStart: false.

On this page