Skip to content

Commit

Permalink
fix(sockets): fix socket unable to send error message crashing server (
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmasse committed Mar 9, 2022
1 parent b7d0a8a commit b18c779
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/server/src/socket/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ export class SocketManager {
}

async setupSocket(socket: Socket.Socket) {
socket.on('message', async (data) => {
await this.handleSocketMessage(socket, data)
socket.on('message', (data) => {
void this.handleSocketMessage(socket, data)
})
socket.on('disconnect', async () => {
await this.handleSocketDisconnect(socket)
socket.on('disconnect', () => {
void this.handleSocketDisconnect(socket)
})
}

Expand All @@ -156,7 +156,11 @@ export class SocketManager {
} catch (e) {
this.logger.error(e, 'An error occured receiving a socket message', message)

return this.reply(socket, message, { error: true, message: 'an error occurred' })
try {
return this.reply(socket, message, { error: true, message: 'an error occurred' })
} catch (e) {
this.logger.error(e, 'An error occured sending an error message to the socket')
}
}
}

Expand Down

0 comments on commit b18c779

Please sign in to comment.