Fix debug dump-ws crashing the controller

When ws was updated to version 8 it came with a breaking change where
message data was no longer utf8 decoded from binary to a string.  The
main codepath handling messages was updated to handle this but the ws
dump path was not resulting in the controller crashing when receiving
a message that is then forwarded to the dumper without decoding.

Fix by decoding the message in the dump-ws path.
This commit is contained in:
Hornwitser committed 2024-01-14 00:42:43 +01:00
1 parent 1f61e49599
commit 32d70a83d1
1 file changed
+1 -1
+1 -1
View File
@@ -107,7 +107,7 @@ export default class WsServer {
socket.on("message", (message: WebSocket.RawData) => {
wsMessageCounter.labels("in").inc();
if (!socket.clusterio_ignore_dump) {
this.controller.debugEvents.emit("message", { direction: "in", content: message });
this.controller.debugEvents.emit("message", { direction: "in", content: message.toString("utf8") });
}
});
let originalSend = socket.send;