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

Can't resolve HttpService #65

Closed
justinpenguin45 opened this issue Apr 27, 2023 · 6 comments
Closed

Can't resolve HttpService #65

justinpenguin45 opened this issue Apr 27, 2023 · 6 comments
Labels
investigation Why is this happening?

Comments

@justinpenguin45
Copy link

justinpenguin45 commented Apr 27, 2023

I have a service which has a dependency on HttpService from nestjs HttpModule. This was working fine and being injected until I gave the class the @InjectableProxy attribute. Now I get this error

Cannot create Proxy provider RequestScopedService (?, RequestHelper). The argument HttpService at index [0] was not found in the ClsModule Context.

Potential solutions:
- If HttpService is a provider from a separate module, make sure to import the module in "ClsModule.forFeatureAsync()" registration

@justinpenguin45
Copy link
Author

Attempted to fix it by adding this on my Module imports - didnt help.

ClsModule.forFeatureAsync(
{imports: [HttpModule],
useClass: HttpService})

I get this error

Cannot create a Proxy provider for HttpService. The class must be explicitly decorated with the @InjectableProxy() decorator to distinguish it from a regular provider.

@justinpenguin45
Copy link
Author

justinpenguin45 commented Apr 27, 2023

Tried this as well, since the RequestScopedService is what has the dependency on HttpService

ClsModule.forFeatureAsync(
{imports: [HttpModule],
// now you can inject DogsService in the DogContext Proxy Provider
useClass: RequestScopedService})

I get this error

Cannot create Proxy provider RequestScopedService (?, RequestHelper). The argument HttpService at index [0] was not found in the ClsModule Context.

Potential solutions:
- If HttpService is a provider from a separate module, make sure to import the module in "ClsModule.forFeatureAsync()" registration

@Papooch
Copy link
Owner

Papooch commented Apr 28, 2023

I believe HttpModule is dynamic, do you need to put

HttpModule.register()

in the imports.

If that does not help, please provide a minimal repoducible example, so I can investigate.

EDIT: actually HttpModule can be used also with a static import, so this should actually work 🤔

@Papooch Papooch added the investigation Why is this happening? label Apr 28, 2023
@Papooch
Copy link
Owner

Papooch commented Apr 28, 2023

I just tried it in the library's test suite and it works as expected
image

So I would again like to ask you for a working example in which you demonstrate the problem you're having.

@Papooch
Copy link
Owner

Papooch commented May 4, 2023

@justinpenguin45 Did you manage to solve your problem on your side, or do you require more assistance?

@Papooch
Copy link
Owner

Papooch commented May 12, 2023

I'm going to assume the issue is solved or no longer relevant, feel free to open a new one when problems arise.

@Papooch Papooch closed this as completed May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation Why is this happening?
Projects
None yet
Development

No branches or pull requests

2 participants