Description
Working with node v8.7.0
Socket io: 2.0.4
Socket-io-parser: 3.1.2
When responding to a message with a large object that serialized to a string larger than ~300MB, we get the exception:
_2017-11-24T04:04:06.732Z - error: RangeError: Invalid string length
at JSON.stringify ()
at encodeAsString (.../node_modules/socket.io-parser/index.js:173:17)
at Encoder.encode (.../node_modules/socket.io-parser/index.js:137:20)
at Manager.packet (.../node_modules/socket.io-client/lib/manager.js:421:18)
at Socket.packet (.../node_modules/socket.io-client/lib/socket.js:173:11)
at .../node_modules/socket.io-client/lib/socket.js:292:10
at then (.../app/runner.js:111:22)
at
at process.tickCallback (internal/process/next_tick.js:188:7)
While getting an error for this is ok (we don't really want these kind of messages to be sent), it gets the entire communication to hang. No more messages can be sent!!!
In order to reproduce you should respond to a message with a very large object (> 300MB) that will get to the JSON.stringify inside encodeAsString (socket.io-parser/index.js) and throw an exception.
PS: any other exception inside the JSON.stringify will hang the channel as well (for example other serialization errors).
Expected behavior: Catch these exceptions and return a proper error message, keeping the channel active.
Thanks,
Assaf