From 3977444bc5b1f701c41014dd107549f0d8e7e817 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Sun, 16 Oct 2022 15:25:10 +0530 Subject: [PATCH] fix: handle errors in validateconnection --- src/Socket/socket.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index e53f97d..b696d8b 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -425,7 +425,14 @@ export const makeSocket = ({ } ws.on('message', onMessageRecieved) - ws.on('open', validateConnection) + ws.on('open', async() => { + try { + await validateConnection() + } catch(err) { + logger.error({ err }, 'error in validating connection') + end(err) + } + }) ws.on('error', error => end( new Boom( `WebSocket Error (${error.message})`,