skychat
skychat copied to clipboard
Fix logging crashing when sending a non-json-able object
[12:05:43.921] INFO (7): Command received: xxxxx /message (length: 51)
[12:05:50.393] ERROR (7): WebSocket error from xxxxxxxxxxx: Error: Invalid WebSocket frame: invalid UTF-8 sequence
file:///workdir/build/server/skychat/Logging.js:4
return args.map((a) => (typeof a === 'string' ? a : JSON.stringify(a))).join(' ');
^
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Room'
| property 'connections' -> object with constructor 'Array'
| index 0 -> object with constructor 'Connection'
--- property 'room' closes the circle
at JSON.stringify (<anonymous>)
at file:///workdir/build/server/skychat/Logging.js:4:66
at Array.map (<anonymous>)
at Logging.argsToString (file:///workdir/build/server/skychat/Logging.js:4:21)
at Logging.error (file:///workdir/build/server/skychat/Logging.js:10:38)
at Connection.<anonymous> (file:///workdir/build/server/skychat/Connection.js:165:21)
at Generator.next (<anonymous>)
at file:///workdir/build/server/skychat/Connection.js:7:71
at new Promise (<anonymous>)
at __awaiter (file:///workdir/build/server/skychat/Connection.js:3:12)
Node.js v22.16.0