Registry / database / plainjob

plainjob

JSON →
library0.0.14jsnpmunverified

plainjob is a lightweight, high-performance job queue backed by SQLite, designed to handle up to 15,000 jobs per second. It supports both bun:sqlite and better-sqlite3 as database drivers, with TypeScript types included. Key differentiators include its minimal dependencies (only better-sqlite3 and a cron-parser), support for delayed jobs, cron-scheduled jobs, automatic cleanup, and job timeout handling. The current stable version is 0.0.14, with active development on GitHub.

npm install plainjob
INSTALL
IMPORT
SIG · PLAINJOB
P
plainjob
databasejavascriptv0.0.14
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

bun
import { bun } from 'plainjob'
const bun = require('plainjob').bun
ESM-only; named export for bun:sqlite connection wrapper.
defineQueue
import { defineQueue } from 'plainjob'
import defineQueue from 'plainjob'
Named export, not default.
defineWorker
import { defineWorker } from 'plainjob'
import { defineWorker } from 'plainjob/worker'
Named export from main module.
better
import { better } from 'plainjob'
import { better } from 'plainjob/better'
Named export for better-sqlite3 connection wrapper.

Sets up a SQLite-backed queue using bun:sqlite, defines a worker for 'print' jobs, enqueues a job, and starts processing.

import { bun, defineQueue, defineWorker } from 'plainjob'; import Database from 'bun:sqlite'; const connection = bun(new Database('data.db', { strict: true })); const queue = defineQueue({ connection }); const worker = defineWorker( 'print', async (job) => { console.log(`Processing job ${job.id}: ${job.data}`); }, { queue } ); queue.add('print', 'Hello, plainjob!'); worker.start();
Debug
Known issues
gotchabun:sqlite must be opened with strict: true mode; otherwise the driver may fail.
fix
Use `new Database('data.db', { strict: true })` when using bun.
affects: >=0.0.1
breakingThe `processAll` function was removed in v0.0.14; use worker.stop() instead.
fix
Replace `processAll(queue)` with `worker.stop()`.
affects: >=0.0.14
deprecatedDirect import of `JobStatus` may be deprecated in future versions.
fix
Use the status string literals instead of enum.
affects: >=0.0.10
gotchaWhen using Node.js, `better-sqlite3` must be installed separately; it is a peer dependency.
fix
Run `npm install plainjob better-sqlite3`.
affects: >=0.0.1
Errors
Common errors & fixes
Error: BetterSqlite3Database is not a constructor
Using the bun driver with Node.js or vice versa.
fix
Use `better()` with a `better-sqlite3` Database instance for Node.js, or `bun()` with `bun:sqlite` Database for Bun.
TypeError: Cannot read properties of undefined (reading 'prepare')
The database connection was not wrapped with `bun()` or `better()`.
fix
Wrap the Database instance: `const connection = bun(new Database('data.db', { strict: true }));`
Error: plainjob requires strict mode for bun:sqlite
bun:sqlite Database opened without { strict: true }.
fix
Create the database with `new Database('path', { strict: true })`.
Upgrade
Version history
0.0.14latest on npm
Audit
Dependencies
better-sqlite3optionalRequired when using Node.js (not bun); provides the SQLite binding.
Agent activity
2 hits · last 30 days
node
2
Resources
plainjob — npm install plainjob · libregistry