Skip to content

Commit

Permalink
fix(): fix concurrency with 0 as a value #590
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Nov 4, 2020
1 parent 25882b8 commit 6034dbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions lib/bull.explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ export class BullExplorer implements OnModuleInit {
isRequestScoped: boolean,
options?: ProcessOptions,
) {
let args: unknown[] = [
options && options.name,
options && options.concurrency,
];
let args: unknown[] = [options?.name, options?.concurrency];

if (isRequestScoped) {
const callback: ProcessCallbackFunction<unknown> = async (
Expand All @@ -112,7 +109,7 @@ export class BullExplorer implements OnModuleInit {
instance[key].bind(instance) as ProcessCallbackFunction<unknown>,
);
}
args = args.filter(item => item !== undefined);
args = args.filter((item) => item !== undefined);
queue.process.call(queue, ...args);
}

Expand Down
8 changes: 4 additions & 4 deletions lib/bull.providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ function buildQueue(option: BullModuleOptions): Queue {
} else if (isProcessorCallback(processor)) {
args.push(processor);
}
args = args.filter(arg => !!arg);
args = args.filter((arg) => typeof arg !== 'undefined');
queue.process.call(queue, ...args);
});
}
((queue as unknown) as OnApplicationShutdown).onApplicationShutdown = function(
((queue as unknown) as OnApplicationShutdown).onApplicationShutdown = function (
this: Queue,
) {
return this.close();
Expand All @@ -45,7 +45,7 @@ function buildQueue(option: BullModuleOptions): Queue {
export function createQueueOptionProviders(
options: BullModuleOptions[],
): Provider[] {
const providers = options.map(option => {
const providers = options.map((option) => {
const optionalSharedConfigHolder = createConditionalDepHolder(
getSharedConfigToken(option.configKey),
);
Expand All @@ -67,7 +67,7 @@ export function createQueueOptionProviders(
}

export function createQueueProviders(options: BullModuleOptions[]): Provider[] {
return options.map(option => ({
return options.map((option) => ({
provide: getQueueToken(option.name),
useFactory: (o: BullModuleOptions) => {
const queueName = o.name || option.name;
Expand Down

0 comments on commit 6034dbc

Please sign in to comment.