fix: stop sending port-in-use errors to Sentry (#558)

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
This commit is contained in:
Dani Akash
2026-03-26 09:32:18 +05:30
committed by GitHub
parent 37ead6d129
commit f45cb58889
2 changed files with 8 additions and 2 deletions

View File

@@ -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)

View File

@@ -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 {