0

I've recently uplifted an Angular application from V12 to v15. On testing the application im seeing that the http interceptors are working fine, except for two http calls. Now there is nothing special about these http calls, they are the exact same as the others (other than the payload and endpoint), they just go without triggering the interceptors.

  • There is only one module in the application, so the issue is not with HTTPClientModule in multiple modules.
  • There are no lazy loaded modules within the application.
  • All interceptors are provided in the main module along with HTTPClientModule.

Also this application is loaded inside another application that controls things like session management, localization etc. i've checked the angular changelog and the only changes I see in relation to interceptors, only applies to standalone components.

For the life of me I can't figure out why it wont work for all http requests. Its alot of code and i'd prefer not to share it all. Im wondering has anybody experienced a similar situation? and if so, how did you fix it? Any help at all would be great.

export function httpErrorHandlingInterceptorServiceFactory(
    globalNotificationService: GlobalNotificationService,
    cbTranslateService: TranslateService,
    AlertService: AlertService
) {
    const errorHandlingInterceptorServiceInstance = new HttpErrorHandlingInterceptorService(
        globalNotificationService,
        searchTranslateService,
        AlertService
    );
    return errrorHandlingInterceptorServiceInstance;
}

@NgModule({
    imports: [
        HttpClientModule,
        CommonModule,
        SearchPluginRoutingModule,
        FormsModule,
        AgGridModule,
    ],
    providers: [
        SearchService,
        SearchEditService,
        TranslateService,
        { provide: HTTP_INTERCEPTORS, useClass: HttpPathInterceptorService, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: HttpSessionInterceptorService, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: HttpAuthInterceptorService, multi: true },
        {
            provide: HTTP_INTERCEPTORS,
            useFactory: httpErrorHandlingInterceptorServiceFactory,
            deps: [GlobalNotificationService, TranslateService, AlertService],
            multi: true,
        },
        {
            provide: HttpErrorHandlingInterceptorService,
            deps: [GlobalNotificationService, TranslateService, AlertService],
            useFactory: httpErrorHandlingInterceptorServiceFactory,
        },
        GlobalNotificationService,
        PageService,
        AlertService,
        SearchEditService,
    ],
    declarations: [
        SearchComponent,
        HasRolesDirective,
        SearchFormComponent,
        SearchDeleteComponent
    ],
})
export class SearchPluginModule {
    constructor(private behaviorRegistryService: BehaviorRegistryService) {
        this.behaviorRegistryService.registerService('testExampleService', BlockService);
    }
}

I've tried changing the order of interceptors - although i know the order is important but i'm lost for ideas, i also created new interceptors, to see if they would get triggered, they get triggered by the other http calls but not the two in question.

Shandy223
  • 1
  • 4

0 Answers0