anchan828 / nest-bull Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
After I've spend some more time researching I could create a small repo to reproduce the issue.
https://github.com/cschroeter/bull-bug/
@anchan828 Would be nice if you could have a look :)
The workflow ci-workflow.yml is referencing action paambaati/codeclimate-action using references v2.7.5. However this reference is missing the commit 62e5eab9c1f8c952f64862c152e205c9c835b755 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.
I will create @anchan828/nest-bullmq package
https://github.com/taskforcesh/bullmq
Hello! First off - thanks for this library!
I'm trying to get a health check working for Bull. I'm following the provided instructions, but I'm getting the following error:
Argument of type '{ redis: { host: string; port: number; }; queues: (typeof BullHealthCheckQueue)[]; }' is not assignable to parameter of type 'QueueOptions'.
Object literal may only specify known properties, and 'queues' does not exist in type 'QueueOptions'.
Here's the relevant code in context:
BullModule.forRoot({
queues: [BullHealthCheckQueue],
}),
And a screenshot for a bit more context.
I feel like I'm missing something obvious (it's late... ๐ฌ) The error makes sense to me - I'm not seeing a queues
property on QueueOptions
which seems to be the type for a single-parameter call to BullModule.forRoot()
.
Any idea what I might be doing wrong? Or, perhaps I have incompatible versions?
Hey looking through your repos you have created some amazing packages. I noticed you are also very familiar with cloud run.
I want to get a bull bullmq working on cloud run. I am using your package: nest-bullmq
I have tried and see that my service is connected to redis, but when an item is added to the queue my service does not pick it up on cloud run. I am wondering if you have any insight?
Thanks!
For now, supports forRootAsync, however we can't inject queue at async. So I will add forQueue function that provide queue in each module.
ex)
@Module({
imports: [BullModule.forQueue([ExampleQueue])],
providers: [ExampleService],
})
export class ExampleModule {}
When class decorated with @BullWorker has multiple methods, all of them are called to process a job in round-robin fashion, despite one decorated with @BullWorkerProcess. This makes @BullWorkerProcess decorator useless. Here is an example of such a worker.
@BullWorker({ queueName })
export class TestBullWorker {
@BullWorkerProcess()
public async process(job: Job): Promise<{ status: string }> {
return { status: "ok" };
}
private somePrivateMethod() {
return false;
}
private anotherPrivateMethodNotSupposedToBeCalled() {
return 5;
}
}
Adding six jobs to queue queueName
results in these values
Expected results are
Here is a code to reproduce (modified basic example)
import { BullModule, BullQueueInject, BullWorker, BullWorkerProcess } from "@anchan828/nest-bullmq";
import { createQueueEvents } from "@anchan828/nest-bullmq/dist/bull.utils";
import { Injectable, Module } from "@nestjs/common";
import { Test } from "@nestjs/testing";
import { Job, Queue } from "bullmq";
const queueName = "queueName";
@BullWorker({ queueName })
export class TestBullWorker {
@BullWorkerProcess()
public async process(job: Job): Promise<{ status: string }> {
expect(job.data).toStrictEqual({ test: "test" });
return { status: "ok" };
}
private somePrivateMethod() {
return false;
}
private anotherPrivateMethodNotSupposedToBeCalled() {
return 5;
}
}
@Injectable()
export class TestService {
constructor(@BullQueueInject(queueName) public readonly queue: Queue) {}
public async addJob(): Promise<Job> {
return this.queue.add("job", { test: "test" });
}
}
@Module({
imports: [BullModule.registerQueue(queueName)],
providers: [TestBullWorker, TestService],
})
export class TestModule {}
@Module({
imports: [
BullModule.forRoot({
options: {
connection: {
host: process.env.REDIS_HOST,
port: parseInt(process.env.REDIS_PORT!),
},
},
}),
TestModule,
],
})
export class ApplicationModule {}
describe("Basic Example", () => {
it("test", async () => {
const app = await Test.createTestingModule({
imports: [ApplicationModule],
}).compile();
await app.init();
const service = app.get<TestService>(TestService);
expect(service).toBeDefined();
expect(service.queue).toBeDefined();
const job = await service.addJob();
const job2 = await service.addJob();
const job3 = await service.addJob();
const job4 = await service.addJob();
const job5 = await service.addJob();
const job6 = await service.addJob();
await expect(job.waitUntilFinished(await createQueueEvents(queueName))).resolves.toStrictEqual({ status: "ok" });
await expect(job2.waitUntilFinished(await createQueueEvents(queueName))).resolves.toStrictEqual(false);
await expect(job3.waitUntilFinished(await createQueueEvents(queueName))).resolves.toStrictEqual(5);
await expect(job4.waitUntilFinished(await createQueueEvents(queueName))).resolves.toStrictEqual({ status: "ok" });
await expect(job5.waitUntilFinished(await createQueueEvents(queueName))).resolves.toStrictEqual(false);
await expect(job6.waitUntilFinished(await createQueueEvents(queueName))).resolves.toStrictEqual(5);
await app.close();
});
});
Hi! ๐
Firstly, thanks for your work on this project! ๐
Problem:
When using the useFactory function in scenarios where the argument types aren't compatible with unknown, TypeScript raises type errors.
Type '(configService: ConfigService) => Promise<{ options: { connection: Redis; prefix: string; }; }>' is not assignable to type '(...args: unknown[]) => BullModuleOptions | Promise<BullModuleOptions>'. Types of parameters 'configService' and 'args' are incompatible. Type 'unknown' is not assignable to type 'ConfigService<Record<string, unknown>, false>'.ts(2322) bull-module.interface.d.ts(23, 5): The expected type comes from property 'useFactory' which is declared here on type 'BullModuleAsyncOptions'
Proposed Solution:
Consider changing the argument type from unknown[] to any[]. This would make the useFactory function more flexible and prevent TypeScript from raising type errors for incompatible argument types.
inject
: This is an array of providers to be injected into the context of the module. The values you provide here can be used as dependencies in the function you define in the useFactory option.
useFactory
: This is a function that will return the actual value of the provider. It can optionally accept arguments, which are dependencies injected by the Nest.js dependency injection system. The dependencies are specified in the inject array.
Given that useFactory
is used to create the value of a provider, and that this function can have injected dependencies, you may find yourself needing to use the injected dependencies without having to narrow down the types first.
Here is the diff that solved my problem:
diff --git a/node_modules/@anchan828/nest-bullmq/dist/interfaces/bull-module.interface.d.ts b/node_modules/@anchan828/nest-bullmq/dist/interfaces/bull-module.interface.d.ts
index 06c5aa1..cb1569f 100644
--- a/node_modules/@anchan828/nest-bullmq/dist/interfaces/bull-module.interface.d.ts
+++ b/node_modules/@anchan828/nest-bullmq/dist/interfaces/bull-module.interface.d.ts
@@ -20,7 +20,7 @@ export interface BullModuleOptions {
export interface BullModuleAsyncOptions extends Pick<ModuleMetadata, "imports"> {
useClass?: Type<BullModuleOptionsFactory>;
useExisting?: Type<BullModuleOptionsFactory>;
- useFactory?: (...args: unknown[]) => Promise<BullModuleOptions> | BullModuleOptions;
+ useFactory?: (...args: any[]) => Promise<BullModuleOptions> | BullModuleOptions;
inject?: Array<Type<BullModuleOptionsFactory> | string | any>;
}
export interface BullModuleOptionsFactory {
BullModule.forRoot({
options: { connection }, // <- required, or create default connection
}),
@BullQueueEvents(queueName)
export class ConnectorEvents {
constructor(
) {}
//Argument of type '"completed"' is not assignable to parameter of type 'QueueListenerType'.ts
@BullQueueEventProcess("completed")
public async process(job): Promise {
}
}
Hey - first of all thanks for this awesome library.
Unfortunately I discovered an isse after updating to NestJS 6. Services in the BullQueueProcess are not defined anymore :(
@BullQueue({ name: JOB_QUEUE })
export class JobQueue {
constructor(private readonly service: Service) {
console.log('Service', { service }); // service defined
}
@BullQueueProcess()
process(job: Job<any>): void {
console.log('Service', { service }); // here the service is not defined
}
I notice that the forRootAsync
is currently commented out. Were there problems with this?
Referring to: https://github.com/anchan828/nest-bull/blob/master/packages/bull/src/bull.module.ts#L15
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@commitlint/cli
, @commitlint/config-conventional
, @lerna-lite/cli
, @lerna-lite/publish
, @nestjs/common
, @nestjs/core
, @nestjs/platform-express
, @nestjs/testing
, @types/node
, @typescript-eslint/eslint-plugin
, @typescript-eslint/parser
, bull
, bullmq
, eslint
, eslint-plugin-prettier
, reflect-metadata
, turbo
)@types/supertest
, bullmq
)docker-compose.yaml
.github/workflows/codeql-analysis.yml
actions/checkout v4
github/codeql-action v3
github/codeql-action v3
github/codeql-action v3
.github/workflows/major-release.yml
volta-cli/action v4.0.1
.github/workflows/minor-release.yml
volta-cli/action v4.0.1
.github/workflows/patch-release.yml
volta-cli/action v4.0.1
.github/workflows/test.yml
actions/checkout v4
actions/setup-node v4
nick-fields/retry v2
codecov/codecov-action v3
package.json
@commitlint/cli 18.4.3
@commitlint/config-conventional 18.4.3
@lerna-lite/cli 3.1.0
@lerna-lite/publish 3.1.0
@nestjs/common 10.2.10
@nestjs/core 10.2.10
@nestjs/platform-express 10.2.10
@nestjs/testing 10.2.10
@types/jest 29.5.11
@types/node 20.10.4
@typescript-eslint/eslint-plugin 6.14.0
@typescript-eslint/parser 6.14.0
eslint 8.55.0
eslint-config-prettier 9.1.0
eslint-plugin-prettier 5.0.1
fast-glob 3.3.2
husky 8.0.3
jest 29.7.0
lint-staged 15.2.0
prettier 3.1.1
reflect-metadata 0.1.14
rxjs 7.8.1
ts-jest 29.1.1
ts-node 10.9.2
turbo 1.11.1
typescript 5.3.3
ulid 2.3.0
node 20.11.0
packages/bull/package.json
deepmerge ^4.3.1
fast-glob ^3.3.1
@nestjs/common 10.2.10
@types/bull 3.15.9
bull 4.11.5
rxjs 7.8.1
@nestjs/common ^8.0.0 || ^9.0.0 || ^10.0.0
packages/bullmq-terminus/package.json
@nestjs/axios 3.0.1
@nestjs/common 10.2.10
@nestjs/terminus 10.2.0
@types/supertest 2.0.16
bullmq 4.15.2
ioredis 5.3.2
rxjs 7.8.1
supertest 6.3.3
@nestjs/axios ^0.0.8 || ^0.1.0 || ^1.0.0 || ^2.0.0 || ^3.0.0
@nestjs/common ^8.0.0 || ^9.0.0 || ^10.0.0
packages/bullmq/package.json
@nestjs/common 10.2.10
bullmq 4.15.2
ioredis 5.3.2
rxjs 7.8.1
@nestjs/common ^8.0.0 || ^9.0.0 || ^10.0.0
packages/terminus/package.json
@nestjs/axios 3.0.1
@nestjs/common 10.2.10
@nestjs/terminus 10.2.0
@types/bull 3.15.9
@types/supertest 2.0.16
bull 4.11.5
rxjs 7.8.1
supertest 6.3.3
@nestjs/axios ^0.0.8 || ^0.1.0 || ^1.0.0 || ^2.0.0 || ^3.0.0
@nestjs/common ^8.0.0 || ^9.0.0 || ^10.0.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.