node-minecraft-protocol
node-minecraft-protocol copied to clipboard
Don't throw errors in framing Splitter class if hideErrors is enabled
Currently, the server occasionally crashes with an error thrown in the Splitter class in the framing.js module:
.../node_modules/minecraft-protocol/src/transforms/framing.js:67
} else { throw e }
^
RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 377. Received -939024210
at new NodeError (node:internal/errors:371:5)
at boundsError (node:internal/buffer:86:9)
at Buffer.readUInt8 (node:internal/buffer:252:5)
at readVarInt (/aternos/nodejs/hypnos/node_modules/protodef/src/datatypes/utils.js:70:22)
at Splitter._transform (/aternos/nodejs/hypnos/node_modules/minecraft-protocol/src/transforms/framing.js:63:30)
at Splitter.Transform._read (/aternos/nodejs/hypnos/node_modules/readable-stream/lib/_stream_transform.js:177:10)
at Splitter.Transform._write (/aternos/nodejs/hypnos/node_modules/readable-stream/lib/_stream_transform.js:164:83)
at doWrite (/aternos/nodejs/hypnos/node_modules/readable-stream/lib/_stream_writable.js:409:139)
at writeOrBuffer (/aternos/nodejs/hypnos/node_modules/readable-stream/lib/_stream_writable.js:398:5)
at Splitter.Writable.write (/aternos/nodejs/hypnos/node_modules/readable-stream/lib/_stream_writable.js:307:11) {
code: 'ERR_OUT_OF_RANGE'
}
This shouldn't happen when the hideErrors option is enabled. I've passed the hideErrors option from the Client to the Splitter and it now only throws the errors when hideErrors is disabled.
I don't think that's a good change This is not a recoverable error It should crash
I'm not sure what exactly is causing this error, but I guess that it's caused by invalid data received from the client? It shouldn't be possible to crash the server through anything sent by the client.
Yeah that makes sense. So the correct thing to do should be closing that client connection.