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

HttpInterceptor not triggering with lazy loaded modules #14

Closed
micobarac opened this issue Feb 6, 2019 · 12 comments
Closed

HttpInterceptor not triggering with lazy loaded modules #14

micobarac opened this issue Feb 6, 2019 · 12 comments
Labels
bug Something isn't working
Milestone

Comments

@micobarac
Copy link

micobarac commented Feb 6, 2019

Custom HttpInterceptor not triggering with lazy loaded modules, when using TranslateModule as stated in docs.

It's a complex project, so I cannot show the example code.

The problem with lazy loaded modules and HttpInterceptor is that HttpClientModule can only be imported once in the project inside app.module.ts. Looking into this library's code, I found that HttpClientModule is imported internally, which, I presume, could cause this problem.

The files to look for these imports are:

projects/translate/src/lib/translate.module.ts
projects/translate/src/lib/translate.pipe.spec.ts
projects/translate/src/lib/title.service.spec.ts
projects/translate/src/lib/translate.service.spec.ts

@DenysVuika DenysVuika added the bug Something isn't working label Feb 6, 2019
@DenysVuika
Copy link
Contributor

Yes, makes sense. While TranslateService is provided in the root, the lazy module makes a copy of HttpClientModule and corresponding providers if any.

Thanks for reporting, I will try to fix this issue and move HttpClientModule to the app level.

@micobarac
Copy link
Author

As the library requires that HttpClientModule should be imported in app.module.ts, HttpClientModule imports should be removed from all the internal files.

@DenysVuika
Copy link
Contributor

@micobarac the unit tests are fine, those need to import HTTP module into the TestBed. Feel free to check this PR and see if that fixes your issue: #15

@DenysVuika DenysVuika added this to the 1.2.0 milestone Feb 6, 2019
@micobarac
Copy link
Author

micobarac commented Feb 7, 2019

@DenysVuika I have tried the commit you suggested and it still doesn't work.

My HttpInterceptor provided inside app.module.ts still doesn't fire.

I think that you haven't removed HttlClientModule from all files but app.module.ts. Can you please check it again? Thanks.

@DenysVuika
Copy link
Contributor

The 1.2 is not published to NPM yet. I removed the file from module but leaving in unit tests, those have nothing to do with your application.

@micobarac
Copy link
Author

I added the latest commit from the git repository, not from NPM.

@DenysVuika
Copy link
Contributor

I may need some example to reproduce the issue. So far the library code has no direct imports of the HttpClientModule if you check the repo.

@micobarac
Copy link
Author

micobarac commented Feb 7, 2019

Perhaps I haven't imported the latest commit well. How do I do it with Yarn, using your Git commit with fix?

@DenysVuika
Copy link
Contributor

I am publishing 1.2.0 right now, you will be able to check in a while directly from NPM

@micobarac
Copy link
Author

Ok, thanks :)

@DenysVuika
Copy link
Contributor

@micobarac
Copy link
Author

I have tried the 1.2.0 version from NPM and it works like a charm.

Thanks a lot.

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