Skip to content

1.1.0

Compare
Choose a tag to compare
@timgit timgit released this 27 Mar 04:20
· 698 commits to master since this release

What's New

Expiration callbacks

While job expiration has always been a thing, reacting to them was not as easy. boss.onExpire(jobName, callback) was added to this release to add a listener explicitly for jobs that have expired.

Failure status

  • failed was added as a job status.
  • pg-boss now emits 'failed' on unhandled subcriber errors instead of 'error', which is far safer considering how node reacts when an EventEmitter emits 'error' when no one is listening. Other unexpected errors during operations will still emit 'error', however.
  • done() in suscribe() callbacks now support passing an error (the popular node convention) to automatically mark the job as failed as well as emitting failed. For exampe, if you are processing a job and you want to explicitly mark it as failed, you can just call done(error) at any time.
  • Finally, boss.fail(jobId) was also added for external failure reporting for the fetch() and complete() crew.

Thanks to @jordansexton for the suggestion on this one. The world is now a better place. 👍

Unsubscribing

boss.unsubscribe(jobName) was added to allow unsubscribing a previous subscribe(). I don't expect this to be very popular, but it does make the API a bit more flexible and aligns subscriptions with the pattern already in place with other methods. For example, stop() reverses start() and disconnect() reverses connect().