diff --git a/packages/browseros-agent/apps/server/src/index.ts b/packages/browseros-agent/apps/server/src/index.ts index 3215c5082..7af085910 100755 --- a/packages/browseros-agent/apps/server/src/index.ts +++ b/packages/browseros-agent/apps/server/src/index.ts @@ -20,6 +20,7 @@ import './lib/polyfill' import { EXIT_CODES } from '@browseros/shared/constants/exit-codes' import { CommanderError } from 'commander' import { loadServerConfig } from './config' +import { isPortInUseError } from './lib/port-binding' import { Sentry } from './lib/sentry' import { Application } from './main' @@ -39,6 +40,9 @@ try { if (error instanceof CommanderError) { process.exit(error.exitCode) } + if (isPortInUseError(error)) { + process.exit(EXIT_CODES.PORT_CONFLICT) + } Sentry.captureException(error) console.error('Failed to start server:', error) process.exit(EXIT_CODES.GENERAL_ERROR) diff --git a/packages/browseros-agent/apps/server/src/main.ts b/packages/browseros-agent/apps/server/src/main.ts index bacab937e..5865d02ad 100644 --- a/packages/browseros-agent/apps/server/src/main.ts +++ b/packages/browseros-agent/apps/server/src/main.ts @@ -231,7 +231,6 @@ export class Application { console.error( `[FATAL] Failed to start ${serverName} on port ${port}: ${errorMsg}`, ) - Sentry.captureException(error) if (isPortInUseError(error)) { console.error( @@ -240,6 +239,7 @@ export class Application { process.exit(EXIT_CODES.PORT_CONFLICT) } + Sentry.captureException(error) process.exit(EXIT_CODES.GENERAL_ERROR) } @@ -255,7 +255,9 @@ export class Application { { port }, ) } - Sentry.captureException(error) + if (!isPortInUseError(error)) { + Sentry.captureException(error) + } } private logStartupSummary(controllerServerStarted: boolean): void {