MCPcopy
hub / github.com/garrytan/gstack / formatExplicitPortUnavailableError

Function formatExplicitPortUnavailableError

browse/src/server.ts:813–827  ·  view source on GitHub ↗
(
  port: number,
  result: Extract<PortCheckResult, { available: false }>
)

Source from the content-addressed store, hash-verified

811}
812
813function formatExplicitPortUnavailableError(
814 port: number,
815 result: Extract<PortCheckResult, { available: false }>
816): Error {
817 if (isOccupiedPort(result)) {
818 return new Error(`[browse] Port ${port} (from BROWSE_PORT env) is in use`);
819 }
820
821 const detail = result.code ? `${result.code}: ${result.message}` : result.message;
822 return new Error(
823 `[browse] Cannot bind BROWSE_PORT=${port} on 127.0.0.1 (${detail}). ` +
824 `This usually means localhost port binding is blocked by the current sandbox or OS permissions, ` +
825 `not that the port is occupied. Allow localhost binding, or run browse from an unrestricted terminal.`
826 );
827}
828
829function formatRandomPortUnavailableError(attempts: FailedPortAttempt[]): Error {
830 const blockingAttempts = attempts.filter((attempt) => !isOccupiedPort(attempt.result));

Callers 1

findPortFunction · 0.85

Calls 1

isOccupiedPortFunction · 0.85

Tested by

no test coverage detected