From f45cb588896ec45156f7520efcefb2a2b71fa44c Mon Sep 17 00:00:00 2001 From: Dani Akash Date: Thu, 26 Mar 2026 09:32:18 +0530 Subject: [PATCH] fix: stop sending port-in-use errors to Sentry (#558) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port conflicts are expected — Chromium retries with a different port. These errors were flooding Sentry (14k+ events) without user impact. - handleStartupError: move Sentry.captureException below the port-in-use check so it only fires for unexpected startup errors - handleControllerStartupError: skip Sentry capture for port errors - index.ts: exit early for port errors before Sentry capture --- packages/browseros-agent/apps/server/src/index.ts | 4 ++++ packages/browseros-agent/apps/server/src/main.ts | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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 {