Skip to Content

Duron

A powerful, type-safe job queue system for Node.js and Bun.js

Duron is a powerful, type-safe job queue system built for Node.js and Bun.js. It provides a robust way to manage background jobs, handle concurrency, retries, and more.

Features

  • Type-Safe - Full TypeScript support with Standard Schema validation (Zod, Valibot, ArkType)
  • Flexible - Support for multiple database backends (PostgreSQL, PGLite)
  • Reliable - Built-in retry logic and error handling
  • Scalable - Multi-process support and concurrency control
  • Observable - Track jobs and steps with detailed status information
  • Simple - Easy-to-use API with sensible defaults

Dashboard

Duron comes with a built-in dashboard for real-time job monitoring and management.

Job List

Job List

Job Output

Job Output

Timeline View

Timeline View

Quick Start

import { duron } from 'duron'
import { defineAction } from 'duron/action'
import { pgliteAdapter } from 'duron/adapters/pglite'
import { z } from 'zod'

const sendEmail = defineAction()({
  name: 'sendEmail',
  input: z.object({
    to: z.string().email(),
    subject: z.string(),
    body: z.string(),
  }),
  handler: async (ctx) => {
    // Use steps to break down work into retryable units
    await ctx.step('sendEmail', async ({ signal }) => {
      console.log(`Sending email to ${ctx.input.to}`)
      // Your email sending logic here
      // The signal can be used to handle cancellation
      const response = await fetch('https://api.email.com/send', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(ctx.input),
        signal,
      })

      if (!response.ok) {
        throw new Error('Failed to send email')
      }
    })

    return { success: true }
  },
})

const client = duron({
  database: pgliteAdapter({ connection: ':memory:' }),
  actions: { sendEmail },
})

await client.start()

const jobId = await client.runAction('sendEmail', {
  to: 'user@example.com',
  subject: 'Hello',
  body: 'This is a test email',
})

Documentation

On this page