bullmq
semver
>=5.0.0 <6.0.0postconditions19functions17last verified2026-04-14coverage score100%Postconditions — what we check
- add · queue-add-redis-errorerrorWhenRedis connection fails or is down during add operationThrows
Error with Redis connection failure detailsRequired handlingCaller MUST wrap Queue.add() in try-catch to handle Redis connection errors. Redis downtime crashes application if unhandled. Use try-catch to gracefully degrade or retry.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - addBulk · queue-addbulk-redis-errorerrorWhenRedis connection fails during bulk operationThrows
Error causing partial or complete bulk operation failureRequired handlingCaller MUST wrap Queue.addBulk() in try-catch to handle Redis errors. Bulk operations can partially fail if Redis connection is lost - must handle to prevent data loss.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - process · worker-process-job-errorwarningWhenjob processing throws error or promise rejectsThrows
Error causing job to fail and trigger retry logic if configuredRequired handlingWorker processor SHOULD handle job errors gracefully with try-catch to control retry behavior and provide meaningful error messages. Unhandled errors in processor can cause worker to stop processing subsequent jobs.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - close · close-errorwarningWhenconnection close operation fails (timeout, Redis error)Throws
Error during connection cleanupRequired handlingCaller SHOULD handle close() errors during graceful shutdown to ensure proper cleanup. Use try-catch in shutdown handlers to log but not crash on close errors.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - run · worker-run-no-error-listenererrorWhenWorker started without 'error' event listener attachedThrows
Unhandled Error event from EventEmitter when Redis errors occurRequired handlingCaller MUST attach worker.on('error', handler) BEFORE calling worker.run(). Without an error listener, Node.js throws an unhandled error event that crashes the process. The BullMQ docs explicitly warn: 'If the error handler is missing, your worker may stop processing jobs when an error is emitted.'costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - run · worker-run-redis-connection-errorerrorWhenRedis connection fails during worker main loopThrows
Error emitted via 'error' event on worker instanceRequired handlingCaller MUST wrap Worker usage with error event listeners. Redis connection loss during run() causes the worker to emit 'error' events. Without maxRetriesPerRequest set to null for consumers, the worker will throw after retry limit is reached.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - FlowProducer.add · flow-add-redis-errorerrorWhenRedis connection fails during atomic flow additionThrows
Error with Redis connection failure detailsRequired handlingCaller MUST wrap FlowProducer.add() in try-catch. Flow additions are atomic (all-or-nothing) via Redis transactions, but Redis connection failure during the transaction causes the entire flow to fail. Without error handling, background pipeline orchestration silently stops.costhighin prodimmediate exceptionusers seedegraded performancevisibilitysilentSources[5] - FlowProducer.addBulk · flow-addbulk-redis-errorerrorWhenRedis connection fails during bulk flow additionThrows
Error with Redis connection failure detailsRequired handlingCaller MUST wrap FlowProducer.addBulk() in try-catch. Bulk flow additions are atomic — Redis failure loses all flows in the batch. Must handle to prevent silent pipeline breakage.costhighin prodimmediate exceptionusers seedegraded performancevisibilitysilentSources[5] - upsertJobScheduler · scheduler-upsert-redis-errorerrorWhenRedis connection fails during scheduler upsertThrows
Error with Redis connection failure detailsRequired handlingCaller MUST wrap upsertJobScheduler() in try-catch. Scheduler creation failure means recurring jobs silently stop being produced. This is especially dangerous during deployment — if scheduler registration fails, no cron jobs run until the next successful registration.costhighin prodsilent failureusers seedegraded performancevisibilitysilentSources[6] - pause · queue-pause-redis-errorwarningWhenRedis connection fails during pause operationThrows
Error with Redis connection failure detailsRequired handlingCaller SHOULD wrap pause() in try-catch. Pause failure during maintenance windows means jobs continue processing when they should be stopped. Handle errors to verify pause actually took effect.costmediumin prodsilent failureusers seedegraded performancevisibilitysilentSources[1] - resume · queue-resume-redis-errorwarningWhenRedis connection fails during resume operationThrows
Error with Redis connection failure detailsRequired handlingCaller SHOULD wrap resume() in try-catch. Resume failure means the queue stays paused — jobs accumulate in waiting state without being processed. Must verify resume succeeded.costmediumin prodsilent failureusers seedegraded performancevisibilitysilentSources[1] - obliterate · queue-obliterate-active-jobs-errorerrorWhenQueue has active jobs and force option is not setThrows
Error indicating queue cannot be obliterated with active jobsRequired handlingCaller MUST wrap obliterate() in try-catch. The method throws if there are active jobs and force=false. Additionally, this is an iterative SCAN-based operation — large queues may fail mid-obliteration on Redis errors, leaving the queue in a partially destroyed state.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - waitUntilFinished · job-wait-until-finished-timeouterrorWhenJob does not complete within the specified TTLThrows
Error indicating job timed outRequired handlingCaller MUST wrap waitUntilFinished() in try-catch. The promise rejects on both job failure AND timeout. Using waitUntilFinished() in request-response patterns (e.g., HTTP handler waits for job result) without timeout handling causes hung requests. Always set a TTL parameter.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[5] - waitUntilFinished · job-wait-until-finished-job-failederrorWhenThe job fails during processingThrows
Error with the job's failedReasonRequired handlingCaller MUST handle rejection from waitUntilFinished(). When the job's processor throws, this promise rejects with the failure reason. Without try-catch, the calling code gets an unhandled rejection.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[5] - Job.remove · job-remove-locked-errorerrorWhenJob is currently being processed by a worker (locked)Throws
Error indicating job is locked and cannot be removedRequired handlingCaller MUST wrap job.remove() in try-catch. Active jobs have locks and cannot be removed — the method throws rather than silently failing. Handle this to implement retry-after-completion logic.costlowin prodimmediate exceptionusers seedegraded performancevisibilityvisibleSources[7] - Job.retry · job-retry-invalid-stateerrorWhenJob is not in failed or completed state, or job does not existThrows
Error indicating job cannot be retried (wrong state, locked, or missing)Required handlingCaller MUST wrap job.retry() in try-catch. The method throws if the job is locked, does not exist, or is not in a finished state. Handle errors to avoid crashing retry-management code.costlowin prodimmediate exceptionusers seedegraded performancevisibilityvisibleSources[8] - clean · queue-clean-redis-errorwarningWhenRedis connection fails during clean operationThrows
Error with Redis connection failure detailsRequired handlingCaller SHOULD wrap clean() in try-catch. Clean operations run Lua scripts against Redis — connection failures leave the queue in an inconsistent state. Handle errors in maintenance/cron code to prevent silent cleanup failures.costlowin prodsilent failureusers seedegraded performancevisibilitysilentSources[1] - drain · queue-drain-redis-errorwarningWhenRedis connection fails during drain operationThrows
Error with Redis connection failure detailsRequired handlingCaller SHOULD wrap drain() in try-catch. Drain failure during deployment/maintenance means stale jobs remain in queue. Handle to verify drain completed.costlowin prodsilent failureusers seedegraded performancevisibilitysilentSources[1] - retryJobs · queue-retryjobs-redis-errorwarningWhenRedis connection fails during batch retry operationThrows
Error with Redis connection failure detailsRequired handlingCaller SHOULD wrap retryJobs() in try-catch. Batch retry operations iterate over potentially large job sets — Redis failure mid-iteration causes partial retries. Handle to track which jobs were actually retried.costmediumin prodsilent failureusers seedegraded performancevisibilitysilentSources[8]
Sources
Every postcondition cites at least one of these. Numbered to match the footnotes above.
- [1]docs.bullmq.io/guide/queueshttps://docs.bullmq.io/guide/queues
- [2]docs.bullmq.io/guide/workershttps://docs.bullmq.io/guide/workers
- [3]docs.bullmq.io/guide/connectionshttps://docs.bullmq.io/guide/connections
- [4]docs.bullmq.io/patterns/failing-fast-when-redis-is-downhttps://docs.bullmq.io/patterns/failing-fast-when-redis-is-down
- [5]docs.bullmq.io/guide/flowshttps://docs.bullmq.io/guide/flows
- [6]docs.bullmq.io/guide/job-schedulershttps://docs.bullmq.io/guide/job-schedulers
- [7]docs.bullmq.io/guide/jobshttps://docs.bullmq.io/guide/jobs
- [8]docs.bullmq.io/guide/retrying-failing-jobshttps://docs.bullmq.io/guide/retrying-failing-jobs
Need a different package?
Request a profile