Skip to content

Commit

Permalink
fix: catch and handle websocket error (#11991) (#12007)
Browse files Browse the repository at this point in the history
Co-authored-by: Samuel Elie <selie@anduril.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
  • Loading branch information
3 people authored Feb 18, 2023
1 parent a0702a1 commit 4b5cc9f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/vite/src/node/server/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ export function createWebSocketServer(
const client = getSocketClient(socket)
listeners.forEach((listener) => listener(parsed.data, client))
})
socket.on('error', (err) => {
config.logger.error(`${colors.red(`ws error:`)}\n${err.stack}`, {
timestamp: true,
error: err,
})
})
socket.send(JSON.stringify({ type: 'connected' }))
if (bufferedError) {
socket.send(JSON.stringify(bufferedError))
Expand Down

0 comments on commit 4b5cc9f

Please sign in to comment.