(
port: number,
result: Extract<PortCheckResult, { available: false }>
)
| 811 | } |
| 812 | |
| 813 | function 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 | |
| 829 | function formatRandomPortUnavailableError(attempts: FailedPortAttempt[]): Error { |
| 830 | const blockingAttempts = attempts.filter((attempt) => !isOccupiedPort(attempt.result)); |
no test coverage detected