npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@node-media-library/bullmq

v1.0.0

Published

BullMQ queue adapter for @node-media-library/core conversion jobs.

Readme

@node-media-library/bullmq

BullMQ queue driver for @node-media-library/core. Pre-release: not yet published to npm.

Install

Once published: npm install @node-media-library/bullmq bullmq bullmq (^5 || ^6) is a required peer dependency. Both majors were verified against a real Redis with the full QueueDriver contract suite; CI runs whichever version the lockfile pins.

On BullMQ 6, also install a Redis client. BullMQ 5 bundled ioredis as a dependency; 6 makes it an optional peer (alongside redis and pg), so it is only present if your package manager auto-installs optional peers — pnpm does, npm and yarn do not. Passing a plain connection object like { url } needs a client, so on npm/yarn run npm install ioredis too. Passing your own client instance instead sidesteps this entirely.

Usage

Wire it into createMediaLibrary via the queue option:

import { createMediaLibrary } from '@node-media-library/core'
import { bullmqDriver } from '@node-media-library/bullmq'

const media = createMediaLibrary({
  repository,
  storage: { disks: { default: { driver: 'fs', root: './storage' } } },
  models: { User: {} },
  queue: bullmqDriver({ connection: { url: process.env.REDIS_URL! } }),
})

Queue/Worker instances are created lazily on first enqueue/work call, so constructing the driver never touches Redis.

Error handling

Queue and Worker are both Node EventEmitters, and Node throws on an unhandled 'error' event — a Redis restart, a dropped connection, or a failed command would otherwise crash the process outright rather than surfacing as a rejected call. This driver always attaches an 'error' listener to both, so that can't happen. By default the listener reports the error with console.error and does nothing else — the connection is not retried and the driver does not close itself. Pass onError to route errors through your own logger, or to exit deliberately (e.g. under a supervisor that restarts the process):

bullmqDriver({
  connection: { url: process.env.REDIS_URL! },
  onError: (err) => {
    logger.error({ err }, 'bullmq broker error')
  },
})

Worker process

bullmqDriver is a BrokerQueueDriver: constructing a MediaLibrary with it never starts consuming — only producing (enqueue) works out of the box. A process that constructs the library and enqueues jobs without ever calling startWorker() pushes those jobs onto the BullMQ queue and leaves them there — nothing in that process (or any other, unless a worker is started separately) ever picks them up. Consuming requires an explicit startWorker() call, made from a dedicated process with the same config, kept alive:

// worker.ts
import { createMediaLibrary } from '@node-media-library/core'
import { bullmqDriver } from '@node-media-library/bullmq'

const media = createMediaLibrary({
  repository,
  storage: { disks: { default: { driver: 'fs', root: './storage' } } },
  models: { User: {} },
  queue: bullmqDriver({ connection: { url: process.env.REDIS_URL! }, workerConcurrency: 4 }),
})

const worker = await media.startWorker() // workerConcurrency above is the default; pass { concurrency }
// to override it per call
process.on('SIGTERM', () => worker.close()) // waits for in-flight jobs; { force: true } to abandon them
// keep the process alive; the worker above processes jobs until closed.

Or via the CLI, given a medialibrary.config.ts that default-exports the same configuration:

node-media-library worker --config medialibrary.config.ts --concurrency 4

Options

bullmqDriver({ connection, queueName, workerConcurrency, onError }): connection is passed straight through to BullMQ's Queue/Worker (ioredis options, an { url } object, or an ioredis instance). queueName defaults to 'media-conversions'. workerConcurrency is the driver-level default for Worker concurrency (defaults to 2), overridden per call by startWorker({ concurrency })'s WorkOptions.concurrency — pass workerConcurrency when you want every worker started from this driver to share a default, and { concurrency } when a specific startWorker() call needs to differ from it. onError receives 'error' events from the underlying Queue/Worker; see "Error handling" above. Defaults to logging via console.error.

Tests

The contract suite (test/driver.test.ts) is Redis-gated: set REDIS_URL to run it against a real broker, e.g. REDIS_URL=redis://localhost:6379 npx vitest run. Without REDIS_URL it skips with a printed warning, and a separate unconditional test confirms construction never touches Redis.