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

registerAsync + global does not work #349

Closed
1 of 4 tasks
JacobSiegle opened this issue Mar 22, 2024 · 3 comments
Closed
1 of 4 tasks

registerAsync + global does not work #349

JacobSiegle opened this issue Mar 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@JacobSiegle
Copy link
Contributor

JacobSiegle commented Mar 22, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

The modules providers are not found even though the module is specified as global.

Minimum reproduction code

https://stackblitz.com/edit/nestjs-typescript-starter-j7sze2?file=src%2Fapp.module.ts&terminal=start

Steps to reproduce

Stackblitz -
Error: Nest can't resolve dependencies of the SubService (?). Please make sure that the argument "CACHE_MANAGER" at index [0] is available in the SubModule context.

Potential solutions:

  • Is SubModule a valid NestJS module?
  • If "CACHE_MANAGER" is a provider, is it part of the current SubModule?
  • If "CACHE_MANAGER" is exported from a separate @module, is that module imported within SubModule?
    @module({
    imports: [ /* the Module containing "CACHE_MANAGER" */ ]
    })

Expected behavior

The modules providers work like register

Package version

2.2.1

NestJS version

10.3.1

Node.js version

18

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@JacobSiegle JacobSiegle added the bug Something isn't working label Mar 22, 2024
@kamilmysliwiec
Copy link
Member

image

@JacobSiegle
Copy link
Contributor Author

@kamilmysliwiec Thanks!

useFactory?: (...args: any[]) => Promise<CacheModuleOptions> | CacheModuleOptions;

CacheModuleOptions has isGlobal when using registerAsync, I noticed you closed but do you think the type is worth fixing?

@kamilmysliwiec
Copy link
Member

Oh yeah it is! Would you like to create a PR?

JacobSiegle added a commit to JacobSiegle/cache-manager that referenced this issue Mar 25, 2024
Reused type CacheModuleOptions causing isGlobal to leak incorrectly into async options.

nestjs#349
JacobSiegle added a commit to JacobSiegle/cache-manager that referenced this issue Mar 25, 2024
Reused type CacheModuleOptions causing isGlobal to leak incorrectly into async options.

nestjs#349
JacobSiegle added a commit to JacobSiegle/cache-manager that referenced this issue Mar 25, 2024
Reused type CacheModuleOptions causing isGlobal to leak incorrectly into async options.

nestjs#349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants