From cfeb2d84eb92dcd0abae5c9353b8b35bc4ecdd39 Mon Sep 17 00:00:00 2001 From: Jeremiah <42397676+jlsnow301@users.noreply.github.com> Date: Sat, 18 Nov 2023 19:23:50 -0800 Subject: [PATCH] Fixes chat bluescreen (#79821) ## About The Pull Request Adds a chat reliability layer reliability layer
more info json.parse claims another ![d86](https://github.com/tgstation/tgstation/assets/42397676/c7d864f2-b5d6-4c5d-95b4-deece37c808d) javascript completely opaque about what throws. innocuous function not wrapped in try/catch block
## Why It's Good For The Game No bluescreen? Fixes #79814 ## Changelog :cl: fix: Chat shouldn't bluescreen at the start of the round /:cl: --- tgui/packages/tgui-panel/chat/middleware.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tgui/packages/tgui-panel/chat/middleware.js b/tgui/packages/tgui-panel/chat/middleware.js index dc81955e906..ecafbd23641 100644 --- a/tgui/packages/tgui-panel/chat/middleware.js +++ b/tgui/packages/tgui-panel/chat/middleware.js @@ -87,7 +87,13 @@ export const chatMiddleware = (store) => { loadChatFromStorage(store); } if (type === 'chat/message') { - const payload_obj = JSON.parse(payload); + let payload_obj; + try { + payload_obj = JSON.parse(payload); + } catch (err) { + return; + } + const sequence = payload_obj.sequence; if (sequences.includes(sequence)) { return;