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

[Nestjs][ExpressAdapter][Bull] HttpAdapterHost isn't available in the BullBoardRootModule context as per #590 #690

Closed
russosalv opened this issue Feb 20, 2024 · 8 comments
Labels
wontfix This will not be worked on

Comments

@russosalv
Copy link

i have same error as per #590

Nest can't resolve dependencies of the BullBoardRootModule (?, bull_board_adapter, bull_board_options). Please make sure that the argument HttpAdapterHost at index [0] is available in the BullBoardRootModule context.

but i have this main.ts

import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import * as appInsights from 'applicationinsights';
import { AppModule } from './app.module';
import { ApplicationInsightInterceptor } from './applicationInsight/applicationInsight.interceptor';
import { ApplicationInsightUtils } from './applicationInsight/applicationInsight.utils';
import { ApplicationInsightLogger } from './applicationInsight/applicationInsightLogger.utils';
import { AuxiliaryJobService } from './modules/auxiliary-job/auxiliary-job-service';
import { GetterJobService } from './modules/getter-job/getter-job.service';
import { SapSyncProcessConfigUtils } from './utils/sapSyncProcessConfig.utils';
import {
	AllExceptionFilter,
	SapRfcNoDataExtractedExceptionFilter,
	TooMuchRunNowJobFilter
} from "./filter/allException.filter";

async function bootstrap() {
	const app = await NestFactory.create(AppModule);

	console.log('DATABASE_URL', process.env.DATABASE_URL);
	console.log('REDIS_HOST', process.env.REDIS_HOST);
	console.log('REDIS_PORT', Number(process.env.REDIS_PORT));

	const applicationInsight = await app.resolve(ApplicationInsightUtils);
	app.useGlobalInterceptors(new ApplicationInsightInterceptor(applicationInsight));

	applicationInsight.defaultClient?.trackEvent({
		name: 'SapSyncV2 Started',
		properties: {
			startTimeUtc: new Date(),
		},
	} as appInsights.Contracts.EventTelemetry);

	const logger = await app.resolve(ApplicationInsightLogger);
	app.useLogger(logger);

	app.useGlobalFilters(new TooMuchRunNowJobFilter(applicationInsight));
	app.useGlobalFilters(new SapRfcNoDataExtractedExceptionFilter(applicationInsight));

	const swaggerConfig = new DocumentBuilder()
		.setTitle('syncV2')
		.setDescription('syncV2')
		.setVersion('2.0')
		.addBearerAuth({ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' })
		.build();

	const document = SwaggerModule.createDocument(app, swaggerConfig, {
		// extraModels: [...PrismaModel.extraModels],
	});
	SwaggerModule.setup('api', app, document);

	const sapSyncProcessConfigUtils = await app.resolve(SapSyncProcessConfigUtils);
	const sapSyncProcessConfigs = await sapSyncProcessConfigUtils.getSapSyncProcessConfigsAll();
	const isFirstSyncAtAll = await sapSyncProcessConfigUtils.isFirstSyncAtAll();

	const getterJobService = await app.resolve(GetterJobService);
	const auxiliaryJobService = await app.resolve(AuxiliaryJobService);

	//** START BEFORE THE REGISTRATION OF QUEUES THEN DISCHARGE DATA */
	// if (isFirstSyncAtAll) {
	// 	await getterJobService.startFirstSync();
	// }
	// await auxiliaryJobService.rescueGetter();
	// await auxiliaryJobService.rescueSetter();
	// await auxiliaryJobService.registerDefault();
	// getterJobService.registerScheduled(sapSyncProcessConfigs);

	app.enableCors({
		origin: '*',
	});

	await app.listen(3000).then(async () => {

		//TODO: REMOVE THIS
		return;

		if (isFirstSyncAtAll) {
			await getterJobService.startFirstSync();
		}
		await auxiliaryJobService.rescueGetter();
		await auxiliaryJobService.rescueSetter();

		await auxiliaryJobService.registerDefault();
		getterJobService.registerScheduled(sapSyncProcessConfigs);
	});
}
bootstrap();
@DennisSnijder
Copy link
Contributor

@russosalv thanks for reporting this!
Where are you registering the BullBoardModule in this example?

Can you give me the following list with the versions you're using?

  • @nestjs/platform-express
  • @nestjs/core
  • @bull-board/nestjs

Cheers!

@russosalv
Copy link
Author

Hi @DennisSnijder

i register BullBoardModule in the app.module.ts

import {SapRfcModule} from "./modules/saprfc/saprfc.module";
import {BullBoardModule} from "@bull-board/nestjs";
import {ExpressAdapter} from "@bull-board/express";




@Module({
	imports: [
		ConfigModule.forRoot(),
		BullModule.forRoot({
			redis: {
				host: process.env.REDIS_HOST ?? 'localhost',
				port: process.env.REDIS_PORT ? Number(process.env.REDIS_PORT) : 6379,
			},
		}),
		ScheduleModule.forRoot(),
		EventEmitterModule.forRoot(),
		AuthModule,
		DeveloperModule,
		GetterJobModule,
		SetterJobModule,
		AuxiliaryJobModule,
		WebsocketClientModule,
		SapRfcModule,
		DbConfigModule,
		BullBoardModule.forRoot({
			route: '/queues',
			adapter: ExpressAdapter
		}),
	],
	controllers: [],
	providers: [
		{
			provide: APP_INTERCEPTOR,
			useClass: ApplicationInsightInterceptor,
		},
		ApplicationInsightLogger,
		ApplicationInsightUtils,
		PrismaService,
		RedisService,
		SapSyncProcessConfigUtils,
		ConfigService,
	],
})
export class AppModule {}

versions are:

	"dependencies": {
		"@bull-board/api": "^5.14.1",
		"@bull-board/express": "^5.14.1",
		"@bull-board/nestjs": "^5.14.1",
		"@nestjs/bull": "^10.0.1",
		"@nestjs/common": "^10.2.7",
		"@nestjs/config": "^3.1.1",
		"@nestjs/core": "^10.2.7",
		"@nestjs/event-emitter": "^2.0.2",
		"@nestjs/platform-express": "^10.2.7",
		"@nestjs/schedule": "^3.0.4",
		"@nestjs/swagger": "^7.1.13",
		"applicationinsights": "^2.8.0",
		"axios": "^1.5.1",
		"bull": "^4.7.0",
		"cronstrue": "^1.125.0",
		"decimal.js": "^10.4.3",
		"easy-soap-request": "^4.6.0",
		"fast-xml-parser": "^4.0.2",
		"keycloak-connect": "^15.0.2",
		"lodash": "^4.17.21",
		"moment": "^2.29.1",
		"moment-timezone": "^0.5.34",
		"nest-keycloak-connect": "^1.7.6",
		"nestjs-sap-rfc": "^3.0.33",
		"prisma-query-log": "^3.2.0",
		"redis": "^4.0.3",
		"reflect-metadata": "^0.1.13",
		"rimraf": "^3.0.2",
		"rxjs": "^7.2.0",
		"socket.io-client": "^4.4.1",
		"string-hash": "^1.1.3",
		"swagger-ui-express": "^5.0.0",
		"uuid": "^8.3.2"
	}

@russosalv
Copy link
Author

russosalv commented Mar 14, 2024

Any Update for that?
still have issue anso using version 5.15.1

@felixmosh
Copy link
Owner

Did you checked examples folder, it works there...

Unfortunately, I'm not so familiar with Nest.js, so I can't help you

@Enflow-io
Copy link

+1

@russosalv
Copy link
Author

i think that the issue is related to yarn version and node version
i'm using node 16 and yarn 1.x

@felixmosh
Copy link
Owner

@russosalv can you confirm that #704 solves this issue?

Copy link

stale bot commented Jun 22, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 22, 2024
@stale stale bot closed this as completed Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants