From 853ee994a68d92a44bbb9bb54e5b9e1a189b7242 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 18 May 2020 18:25:27 +0200 Subject: [PATCH] [perf] add a few short cuts to the packet decoding --- services/real-time/socket.io.patch.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/real-time/socket.io.patch.js b/services/real-time/socket.io.patch.js index 796f8c7574..354d8223c3 100644 --- a/services/real-time/socket.io.patch.js +++ b/services/real-time/socket.io.patch.js @@ -47,3 +47,13 @@ function patchedFrameHandler(opcode, str) { } return outputBuffer; } + +const parser = require('socket.io/lib/parser') +const decodePacket = parser.decodePacket +parser.decodePacket = function (data) { + if (typeof data !== 'string') return {} + const firstColon = data.indexOf(':') + if (firstColon === -1) return {} + if (data.indexOf(':', firstColon + 1) === -1) return {} + return decodePacket(data) +}