Skip to content

Commit

Permalink
Print port in the logged error message after failed WS connection w…
Browse files Browse the repository at this point in the history
…ith `EADDRINUSE`
  • Loading branch information
Andarist authored Jan 16, 2025
1 parent 4f5845a commit 980d6da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/server/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ export function createWebSocketServer(
wss.emit('connection', ws, req)
})
})
wsHttpServer.on('error', (e: Error & { code: string }) => {
wsHttpServer.on('error', (e: Error & { code: string; port: number }) => {
if (e.code === 'EADDRINUSE') {
config.logger.error(
colors.red(`WebSocket server error: Port is already in use`),
colors.red(`WebSocket server error: Port ${e.port} is already in use`),
{ error: e },
)
} else {
Expand Down

0 comments on commit 980d6da

Please sign in to comment.