Skip to content

Commit

Permalink
fix: add check in each one of bull queue adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Oct 29, 2024
1 parent ff52103 commit d0e42c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/api/src/queueAdapters/bull.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Job, Queue } from 'bull';
import BullQueue from 'bull';
import {
JobCleanStatus,
JobCounts,
Expand All @@ -13,6 +14,10 @@ import { BaseAdapter } from './base';
export class BullAdapter extends BaseAdapter {
constructor(public queue: Queue, options: Partial<QueueAdapterOptions> = {}) {
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<string> {
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/queueAdapters/bullMQ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { BaseAdapter } from './base';
export class BullMQAdapter extends BaseAdapter {
constructor(private queue: Queue, options: Partial<QueueAdapterOptions> = {}) {
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<string> {
Expand Down

0 comments on commit d0e42c7

Please sign in to comment.