Skip to content

12.25.0

Choose a tag to compare

@timgit timgit released this 02 Jul 17:30
· 651 commits to master since this release
99a78fd

What's Changed

New: update()

Update the payload and/or options of one or more not-yet-active jobs (state created or retry). Terminal or active jobs can't be touched.

  • Target with exactly one of options.id (single job) or options.singletonKey (jobs sharing a key).
  • Partial updates — only the fields you supply change; omitted options keep their current values. Pass just data to replace the payload without disturbing startAfter, priority, retry settings, etc. Pass undefined for data to edit options only; null clears it.
  • singletonKey and the throttle slot (singletonOn) are always preserved.
  • When several pre-active jobs share a key, options.match picks which are updated by createdOn: newest (default), oldest, or all.
  • If an updated job becomes runnable on a LISTEN/NOTIFY-enabled queue, a wake-up notification fires so idle workers pick it up promptly.
  • Returns { jobs, updated }.
// by id
await boss.update('email', { to: 'a@b.co' }, { id: jobId })

// by singletonKey — overwrite the queued job with the latest body
await boss.update('article', { articleId: 42, body: '…latest…' }, { singletonKey: 'article-42' })

// object overload; data optional
await boss.update({ name: 'article', options: { singletonKey: 'article-42', priority: 5 } })

Updatable fields: data, priority, startAfter, retryLimit, retryDelay, retryBackoff, retryDelayMax, expireInSeconds, retentionSeconds, deleteAfterSeconds, deadLetter, heartbeatSeconds, group.

New: upsert()

Update-or-insert in one call: it runs update() first, and if nothing matched, falls back to insert(). Same targeting and match semantics as update(). When matching by id, the inserted job is created with that id.

  • Returns { jobs, updated, inserted } — on a hit, updated reflects the change and inserted is 0; on a miss, inserted is 1 and jobs holds the new id.
  • Object overload supported, mirroring update().
// ensure exactly one queued job carries the latest article body
await boss.upsert('article', { articleId: 42, body: '…latest…' }, { singletonKey: 'article-42' })

Type fixes

  • Fix public type for spies
  • Dropped obsolete keepUntil insertion-time type

Full Changelog: 12.24.1...12.25.0