Prod build failing with version 11.2.0
export function configureAuth(oidcConfigService: OidcConfigService, httpClient: HttpClient) {
const setupAction$ = httpClient.get<any>(`${window.location.origin}/api/ClientAppSettings`).pipe(
map((customConfig) => {
return {
stsServer: customConfig.stsServer,
authWellknownEndpoint: 'https://login.microsoftonline.com/common/v2.0',
redirectUrl: customConfig.redirect_url,
clientId: customConfig.client_id,
scope: customConfig.scope,
responseType: customConfig.response_type,
silentRenew: true,
maxIdTokenIatOffsetAllowedInSeconds: 600,
issValidationOff: true,
autoUserinfo: false,
silentRenewUrl: window.location.origin + '/silent-renew.html',
// autoUserinfo: false,
};
}),
switchMap((config) => oidcConfigService.withConfig(config))
);
return () => setupAction$.toPromise();
}
@NgModule({
declarations: [
AppComponent,
HomeComponent,
AutoLoginComponent,
ForbiddenComponent,
ProtectedComponent,
UnauthorizedComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
MaterialModule,
AppRoutingModule,
HttpClientModule,
AuthModule.forRoot(),
FlexLayoutModule,
AppStoreModule,
],
providers: [
OidcConfigService,
{
provide: APP_INITIALIZER,
useFactory: configureAuth,
deps: [OidcConfigService, HttpClient],
multi: true,
},
AuthorizationGuard,
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
],
bootstrap: [AppComponent],
entryComponents: [ LogoutComponent],
})
export class AppModule {}
Error: StaticInjectorError(AppModule)[OidcConfigService -> ConfigValidationService]:
StaticInjectorError(Platform: core)[OidcConfigService -> ConfigValidationService]:
NullInjectorError: No provider for ConfigValidationService!
Thanks for reporting!
Greetings Damien
closing this now
moved the problem to a branch were we can fix this. Thanks for reporting
Hey @damienbod! I am experiencing the same exact error. Did you have time to take a look at it? If so, at what brach are you solving the issue? Thanks in advance!
@cvbc2010, We have the same problem! Did you find any workaround? Do we have to wait for a fix from @damienbod?
Thanks!
Hi @polo070770 @JoanGil This is not in the master anymore. The bug has been removed to a branch which still fails. The master branch no longer has this problem.
Greetings Damien
@damienbod what version of npm package has this bug been removed? I have tried 11.2.0, and 11.1.4 and still running into same error.
I will try to reproduce using this example
@damienbod what version of npm package has this bug been removed? I have tried 11.2.0, and 11.1.4 and still running into same error.
Me too.
we seem to have 2 issues here in this issue. The production build failed due to a PR which was merged. This is fixed and no npm was ever released with the bug.
The other issue is from the last release which was 2 months ago.
Hey, thanks for reporting the issue. I tried to reproduce with no success. Can you please tell us what you did to reproduce the issue? Help us to help you a bit :)
What I did was:
1) Creating a new project with Angular 9 ng new testApp
2) ng build --prod which worked fine
3) installed the package with npm install angular-auth-oidc-client
4) ng build --prod which worked fine
5) copied the code in the issue into the app.module.ts
6) ng build --prod which worked fine
7) Creating a new project with Angular 10 ng new testAppAngular10
8) ng build --prod which worked fine
9) installed the package with npm install angular-auth-oidc-client
10) ng build --prod which worked fine
11) copied the code in the issue into the app.module.ts
12) ng build --prod which worked fine
Find my code with the different angular versions here https://github.com/FabianGosebrink/angular-auth-oidc-client-858-repro
Please check out the repo _without modifications_ and let run the ng build --prod to see if it works on your machine and _then_ do a PR with your changes to reproduce the issue.
@cvbc2010, We have the same problem! Did you find any workaround? Do we have to wait for a fix from @damienbod?
Thanks!
as temporary fix i just disabled "buildOptimizer" in angular.json for prod build configuration. it was working from then.
Hey @cvbc2010 , please check the sample repo. The buildOptimizer is set to true both times. I doubt that this is the issue.
@cvbc2010, We have the same problem! Did you find any workaround? Do we have to wait for a fix from @damienbod?
Thanks!as temporary fix i just disabled "buildOptimizer" in angular.json for prod build configuration. it was working from then.
This is what worked for me as well. Thank you for posting your fix.
Closing this as it works on the repo I provided. If anybody wants to add a repro for the bug in the given repo I would be glad to fix this. Would be really interested in where the problem really is. Thanks everybody.
A piece of relevant information could be:
The production build does not fail actually. When you run the production build (build with "buildOptimizer" set to true) you get the aforementioned error when you access the application.
Hey @dbk-fkoller , thanks for your answer but I doubt that. My example repo given above has set the buildOptimizer to true and builds in production just fine.
Thanks.
Building works! Running does not ;-)
Ahhhhhh, thanks!!!! So this is how I can reproduce! Thanks facepalm. Thanks for the hint!! When I can reproduce I can (hopefully) fix it :)
Thanks for your responses - glad I could help a little.
I will stick to the workaround mentioned before for now. Best Regards!
You could totally. I will reproduce and hopefully see the error then. Until then please stick with the workaround.
Sorry, guys, but I can not reproduce the issue. What I did was:
testAppangular-auth-oidc-clientnpm start -- --prod --> worksnpm run build -- --prod --> worksdist folder, serving the distribution, No error in console.
I really need your help to reproduce the issue. I am asking again: Can you please please provide a minimal sample repository that we can fix this? You can fork and my repro repo add a PR if you want.
The first comment here says, that the error is on build.
Prod build failing with version 11.2.0
Then we saw that the error is on executing?
you get the aforementioned error when you access the application.
What is access the application? Access on ng serve? Access on ng serve --prod? Access on the built one in a browser with an html server?
Please help us to help you.
Thanks
Hey,
sorry for getting back so late - I had a busy week :-)
I can confirm your test repository not producing the mentioned issue. I will try to setup a minimal demo project reproducing the issue.
My guess right now: Versioning
We were working on a prototype project (garbage bin here we come). Due to time frame we did not upgrade the project to Angular 9/10 and are stuck on Angular 8.3 and Typescript 3.5.3.
If this really is the case you can probably ignore this issue.
An upgrade to the current version of Angular and Typescript is necessary anyway and the sensible way to fix this. A workaround, albeit an awkward one, is already documented (set "buildOptimizer": false).
I will check if my guess is correct and prepare something. Could be 1-2 weeks, some days off work incoming :-)
Thanks alot for your effort and patience in trying to help us! :rocket:
Hey @dbk-fkoller , thanks for the answer and the feedback. Sure, just let us know here if you find something new :) Appreciate your help! let me know if I can help you. Cheers and take care.
Hey,
you can find a reproduction repository at https://github.com/dbk-fkoller/angular-auth-oidc-client-858-repro
reproduce issue
Uncaught NullInjectorError: StaticInjectorError(AppModule)[OidcConfigService -> ConfigValidationService]:
StaticInjectorError(Platform: core)[OidcConfigService -> ConfigValidationService]:
NullInjectorError: No provider for ConfigValidationService!
resolve issue via an update to at least Angular 9.1.12 && Typescript 3.8.3
Since this seems to be a versioning issue I feel stupid for refiring this. My apologies.
Best Regards and keep up the good work!
Most helpful comment
Ahhhhhh, thanks!!!! So this is how I can reproduce! Thanks facepalm. Thanks for the hint!! When I can reproduce I can (hopefully) fix it :)