'Nest.js axios HttpModule freezes app initialization

I have a module that goes like this:

import { Module } from '@nestjs/common'
import { OtpService } from '@modules/auth/otp/otp.service'
import { OtpResolver } from '@modules/auth/otp/otp.resolver'
import { HttpModule } from '@nestjs/axios'

@Module({
  providers: [OtpResolver, OtpService],
  imports: [
    HttpModule.register({
      timeout: 5000,
      baseURL: "some url"
    }),
  ],
})

export class OtpModule {}

and then it is imported in app module:

import { OtpModule } from '@modules/auth/otp/otp.module'

@Module({
  imports: [
    ....
    OtpModule,
    GraphQLModule.forRootAsync({
      useClass: GraphqlConnectionService,
    }),
  ],
  providers: [AppConfigService],
})

export class AppModule {}

everything works if I remove otp module, it also works if HttpModule is not imported there. I was going by this tutorial but id doesn't seem to work. Any ideas on how to fix this would be very helpful.

UPD: it just freezes on init, here is the output log, all the other modules are initialized correctly and when it comes to otp, it just stops there

{"level":"info","message":"TypegooseModule dependencies initialized"}
{"level":"info","message":"TypegooseModule dependencies initialized"}
{"level":"info","message":"TypegooseModule dependencies initialized"}
{"level":"info","message":"TypegooseModule dependencies initialized"}
{"level":"info","message":"GraphQLModule dependencies initialized"}


Solution 1:[1]

I had the same problem, I fixed it by importing HttpService and HttpModule from @nestjs/axios

replacing

import { Injectable, HttpService } from '@nestjs/common';

For this

import { HttpService } from '@nestjs/axios';

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ion