Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation for registerQueueAsync #2816

Open
2 of 4 tasks
clintonb opened this issue Aug 3, 2023 · 3 comments
Open
2 of 4 tasks

Improve documentation for registerQueueAsync #2816

clintonb opened this issue Aug 3, 2023 · 3 comments

Comments

@clintonb
Copy link

clintonb commented Aug 3, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Registering a queue via registerQueueAsync does not work. The application fails to start:

[Nest] 6149  - 08/02/2023, 6:50:24 PM     LOG [NestFactory] Starting Nest application...
[Nest] 6149  - 08/02/2023, 6:50:24 PM     LOG [InstanceLoader] BullModule dependencies initialized +7ms
[Nest] 6149  - 08/02/2023, 6:50:24 PM     LOG [InstanceLoader] DiscoveryModule dependencies initialized +1ms
[Nest] 6149  - 08/02/2023, 6:50:24 PM     LOG [InstanceLoader] AppModule dependencies initialized +0ms
[Nest] 6149  - 08/02/2023, 6:50:24 PM   ERROR [ExceptionHandler] Nest can't resolve dependencies of the AudioController (?). Please make sure that the argument BullQueue_audio at index [0] is available in the AudioModule context.

Potential solutions:
- Is AudioModule a valid NestJS module?
- If BullQueue_audio is a provider, is it part of the current AudioModule?
- If BullQueue_audio is exported from a separate @Module, is that module imported within AudioModule?
  @Module({
    imports: [ /* the Module containing BullQueue_audio */ ]
  })

Error: Nest can't resolve dependencies of the AudioController (?). Please make sure that the argument BullQueue_audio at index [0] is available in the AudioModule context.

Potential solutions:
- Is AudioModule a valid NestJS module?
- If BullQueue_audio is a provider, is it part of the current AudioModule?
- If BullQueue_audio is exported from a separate @Module, is that module imported within AudioModule?
  @Module({
    imports: [ /* the Module containing BullQueue_audio */ ]
  })

    at Injector.lookupComponentInParentModules (/Users/clintonb/workspace/clintonb/nest/sample/26-queues/node_modules/@nestjs/core/injector/injector.js:248:19)
    at Injector.resolveComponentInstance (/Users/clintonb/workspace/clintonb/nest/sample/26-queues/node_modules/@nestjs/core/injector/injector.js:202:33)
    at resolveParam (/Users/clintonb/workspace/clintonb/nest/sample/26-queues/node_modules/@nestjs/core/injector/injector.js:123:38)
    at async Promise.all (index 0)
    at Injector.resolveConstructorParams (/Users/clintonb/workspace/clintonb/nest/sample/26-queues/node_modules/@nestjs/core/injector/injector.js:138:27)
    at Injector.loadInstance (/Users/clintonb/workspace/clintonb/nest/sample/26-queues/node_modules/@nestjs/core/injector/injector.js:64:13)
    at Injector.loadController (/Users/clintonb/workspace/clintonb/nest/sample/26-queues/node_modules/@nestjs/core/injector/injector.js:82:9)
    at /Users/clintonb/workspace/clintonb/nest/sample/26-queues/node_modules/@nestjs/core/injector/instance-loader.js:68:13
    at async Promise.all (index 0)
    at InstanceLoader.createInstancesOfControllers (/Users/clintonb/workspace/clintonb/nest/sample/26-queues/node_modules/@nestjs/core/injector/instance-loader.js:67:9)

Minimum reproduction code

https://github.com/clintonb/nest/tree/f1c60d26abbae6ec3027ab09e2859ec1bbaa2f07/sample/26-queues/src

Steps to reproduce

Run the reproduction repo: at https://github.com/clintonb/nest/tree/f1c60d26abbae6ec3027ab09e2859ec1bbaa2f07/sample/26-queues/src.

I replaced registerQueue with registerQueueAsync.

Expected behavior

The application should start, and the queue should be registered/usable.

Package version

10.0.1

Bull version

4.10.4

NestJS version

10.0.3

Node.js version

16.20.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@clintonb
Copy link
Author

clintonb commented Aug 3, 2023

Actually, I was able to make this work by declaring name outside of useFactory:

imports: [
  BullModule.registerQueueAsync({
    name: 'audio',
    useFactory: async () =>
      ({
        name: 'audio',
      })
  }),
],

This needs to be better-documented.

@micalevisk
Copy link
Member

@clintonb feel free to improve the docs on that somehow: https://docs.nestjs.com/techniques/queues#async-configuration

@Kamilczak020
Copy link

I can confirm this behavior, experienced this just earlier today.

@clintonb clintonb changed the title registerQueueAsync does not work Improve documentation for registerQueueAsync Aug 3, 2023
@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/bull Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants