diff --git a/packages/backend/package.json b/packages/backend/package.json index 5241cb11e1..5159a3c559 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -55,6 +55,7 @@ "nestjs-spelunker": "^1.3.1", "nestjs-zod": "^4.2.0", "node-cron": "^3.0.3", + "pg": "^8.13.1", "rabbitmq-client": "^5.0.1", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1", @@ -105,7 +106,6 @@ "vite-tsconfig-paths": "5.1.4", "vitest": "^2.1.8", "vitest-mock-extended": "^2.0.2", - "wait-for-expect": "^3.0.2", - "pg": "^8.13.1" + "wait-for-expect": "^3.0.2" } } diff --git a/packages/backend/src/modules/queue/queue.factory.ts b/packages/backend/src/modules/queue/queue.factory.ts index 2f2a2e13ce..43227cf1a4 100644 --- a/packages/backend/src/modules/queue/queue.factory.ts +++ b/packages/backend/src/modules/queue/queue.factory.ts @@ -1,4 +1,6 @@ +import { LoggerService } from '@/core/logger/logger.service'; import { Injectable } from '@nestjs/common'; +import Sentry from '@sentry/nestjs'; import { Connection } from 'rabbitmq-client'; import { type ZodSchema, z } from 'zod'; import { Queue } from './queue.entity'; @@ -7,12 +9,17 @@ import { Queue } from './queue.entity'; export class QueueFactory { private rabbit: Connection; - public constructor() { + public constructor(private readonly logger: LoggerService) { this.initializeConnection(); } private initializeConnection() { this.rabbit = new Connection({ url: 'amqp://guest:guest@localhost:5672' }); + + this.rabbit.on('error', (error) => { + this.logger.error('RabbitMQ connection error:', error); + Sentry.captureException(error); + }); } public createQueue(params: { diff --git a/packages/backend/src/tests/integration/app-lifecycle.test.ts b/packages/backend/src/tests/integration/app-lifecycle.test.ts index 0ca18557e5..439d5cd67e 100644 --- a/packages/backend/src/tests/integration/app-lifecycle.test.ts +++ b/packages/backend/src/tests/integration/app-lifecycle.test.ts @@ -4,6 +4,7 @@ import { ConfigurationService } from '@/core/config/configuration.service'; import { DatabaseService } from '@/core/database/database.service'; import { appStore } from '@/core/database/drizzle/schema'; import { FilesystemService } from '@/core/filesystem/filesystem.service'; +import type { LoggerService } from '@/core/logger/logger.service'; import { AppLifecycleCommandFactory } from '@/modules/app-lifecycle/app-lifecycle-command.factory'; import { AppLifecycleService } from '@/modules/app-lifecycle/app-lifecycle.service'; import { AppStoreRepository } from '@/modules/app-stores/app-store.repository'; @@ -34,7 +35,8 @@ describe('App lifecycle', () => { let appsRepository: AppsRepository; let configurationService = mock(); let databaseService = mock(); - const queueFactory = new QueueFactory(); + const loggerService = mock(); + const queueFactory = new QueueFactory(loggerService); const appEventsQueue = queueFactory.createQueue({ queueName: 'app-events-queue', workers: 1, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 58ee890358..9d62168c6d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -137,6 +137,9 @@ importers: node-cron: specifier: ^3.0.3 version: 3.0.3 + pg: + specifier: ^8.13.1 + version: 8.13.1 rabbitmq-client: specifier: ^5.0.1 version: 5.0.1 @@ -252,9 +255,6 @@ importers: msw: specifier: ^2.6.8 version: 2.6.8(@types/node@22.10.1)(typescript@5.7.2) - pg: - specifier: ^8.13.1 - version: 8.13.1 source-map-support: specifier: ^0.5.21 version: 0.5.21