From 69c0560a25c4c7bb6625090d854ddd6a39ff0f7a Mon Sep 17 00:00:00 2001 From: Jing Date: Thu, 6 Jan 2022 11:20:06 -0500 Subject: [PATCH] Don't update agent_id_to_socket when the key is already deleted (#637) * server.js don't update agent_id_to_socket when the key is already deleted * lint --- mephisto/abstractions/architects/router/deploy/server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mephisto/abstractions/architects/router/deploy/server.js b/mephisto/abstractions/architects/router/deploy/server.js index 0b403d685..c195f039f 100644 --- a/mephisto/abstractions/architects/router/deploy/server.js +++ b/mephisto/abstractions/architects/router/deploy/server.js @@ -382,7 +382,10 @@ wss.on("connection", function (socket) { agent.last_ping = Date.now(); packet.data.status = agent.status; packet.data.state = agent.state; - if (agent_id_to_socket[agent.agent_id] != socket) { + if ( + agent_id_to_socket[agent.agent_id] != socket && + agent_id_to_socket[agent.agent_id] != undefined + ) { // Not communicating to the correct socket, update debug_log("Updating socket for ", agent); agent_id_to_socket[agent.agent_id] = socket;