From d0e42c7bf689400a4768e806ed1c774bafe77cab Mon Sep 17 00:00:00 2001 From: Felix Mosheev <9304194+felixmosh@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:37:42 +0200 Subject: [PATCH] fix: add check in each one of bull queue adapters --- packages/api/src/queueAdapters/bull.ts | 5 +++++ packages/api/src/queueAdapters/bullMQ.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/packages/api/src/queueAdapters/bull.ts b/packages/api/src/queueAdapters/bull.ts index bf50c5e1..71cfdee5 100644 --- a/packages/api/src/queueAdapters/bull.ts +++ b/packages/api/src/queueAdapters/bull.ts @@ -1,4 +1,5 @@ import { Job, Queue } from 'bull'; +import BullQueue from 'bull'; import { JobCleanStatus, JobCounts, @@ -13,6 +14,10 @@ import { BaseAdapter } from './base'; export class BullAdapter extends BaseAdapter { constructor(public queue: Queue, options: Partial = {}) { super('bull', { ...options, allowCompletedRetries: false }); + + if (!(queue instanceof BullQueue)) { + throw new Error(`You've used the Bull adapter with a non-Bull queue.`); + } } public getRedisInfo(): Promise { diff --git a/packages/api/src/queueAdapters/bullMQ.ts b/packages/api/src/queueAdapters/bullMQ.ts index 48959424..1618d032 100644 --- a/packages/api/src/queueAdapters/bullMQ.ts +++ b/packages/api/src/queueAdapters/bullMQ.ts @@ -13,6 +13,9 @@ import { BaseAdapter } from './base'; export class BullMQAdapter extends BaseAdapter { constructor(private queue: Queue, options: Partial = {}) { super('bullmq', options); + if (!(queue instanceof Queue)) { + throw new Error(`You've used the BullMQ adapter with a non-BullMQ queue.`); + } } public async getRedisInfo(): Promise {