From b83c123939e62a1fbdf41504078e40dec6cc6b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Falala-Sechet?= Date: Tue, 2 Jul 2019 16:55:54 +0200 Subject: [PATCH] chore: if an error occurs during the $connect action, close the connection --- src/ApiGatewayWebSocket.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ApiGatewayWebSocket.js b/src/ApiGatewayWebSocket.js index 276cb8e2a..d48ecd5ab 100644 --- a/src/ApiGatewayWebSocket.js +++ b/src/ApiGatewayWebSocket.js @@ -94,6 +94,11 @@ module.exports = class ApiGatewayWebSocket { ws.send(JSON.stringify({ message:'Internal server error', connectionId, requestId:'1234567890' })); } + // mimic AWS behaviour (close connection) when the $connect action handler throws + if (name === '$connect') { + ws.close(); + } + debugLog(`Error in handler of action ${action}`, err); };