darrachequesne / notepack

A fast Node.js implementation of the latest MessagePack spec
MIT License
75 stars 19 forks source link

node 10 support and buffer problems #19

Closed muayyad-alsadi closed 5 years ago

muayyad-alsadi commented 5 years ago

when running node 10 I got

(node:30213) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

for more information:

and I got the following trace when used with socket.io-redis adaptor (which uses your package)

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 111. Received 112

"trace":
[{"column":9,"file":"internal/buffer.js","function":"boundsError","line":53,"method":null,"native":false},
{"column":5,"file":"internal/buffer.js","function":"Buffer.readUInt8","line":141,"method":"readUInt8","native":false},
{"column":28,"file":"node_modules/notepack.io/lib/decode.js","function":"Decoder.parse","line":86,"method":"parse","native":false},
{"column":23,"file":"node_modules[92/2071].io/lib/decode.js","function":"Decoder.map","line":20,"method":"map","native":false},
{"column":19,"file":"node_modules/notepack.io/lib/decode.js","function":"Decoder.parse","line":58,"method":"parse","native":false},
{"column":21,"file":"node_modules/notepack.io/lib/decode.js","function":"Decoder.array","line":11,"method":"array","native":false},
{"column":19,"file":"node_modules/notepack.io/lib/decode.js","function":"Decoder.parse","line":62,"method":"parse","native":false},
{"column":23,"file":"node_modules/notepack.io/lib/decode.js","function":"Object.decode","line":244,"method":"decode","native":false},
{"column":24,"file":"node_modules/socket.io-redis/index.js","function":"Redis.onmessage","line":148,"method":"onmessage","native":false},
{"column":13,"file":"events.js","function":"RedisClient.emit","line":182,"method":"emit","native":false},
{"column":18,"file":"node_modules/redis/index.js","function":"return_pub_sub","line":796,"method":null,"native":false},
{"column":9,"file":"node_modules/redis/index.js","function":"RedisClient.return_reply","line":833,"method":"return_reply","native":false},
{"column":18,"file":"node_modules/redis/index.js","function":"JavascriptRedisParser.returnReply","line":192,"method":"returnReply","native":false},
{"column":12,"file":"node_modules/redis-parser/lib/parser.js","function":"JavascriptRedisParser.execute","line":574,"method":"execute","native":false},
{"column":27,"file":"node_modules/redis/index.js","function":null,"line":274,"method":null,"native":false},
{"column":13,"file":"events.js","function":"Socket.emit","line":182,"method":"emit","native":false},
{"column":12,"file":"_stream_readable.js","function":"addChunk","line":283,"method":null,"native":false},
{"column":11,"file":"_stream_readable.js","function":"readableAddChunk","line":264,"method":null,"native":false},
{"column":10,"file":"_stream_readable.js","function":"Socket.Readable.push","line":219,"method":"push","native":false},
{"column":17,"file":"internal/stream_base_commons.js","function":"TCP.onStreamRead [as onread]","line":94,"method":"onStreamRead [as onread]","native":false}],
muayyad-alsadi commented 5 years ago

the reason of the error is that buf.readUInt8(offset) no longer have noAssert param

| v10.0.0 | Removed noAssert and no implicit coercion of the offset to uint32 anymore. |

https://nodejs.org/docs/latest-v10.x/api/buffer.html#buffer_buf_readuint8_offset

darrachequesne commented 5 years ago

That should be fixed in version 2.2.0 (thanks to this commit), I'll update the version in the socket.io-redis project.

muayyad-alsadi commented 5 years ago

@darrachequesne this covers the warning, but does it cover the removal of noAssert?

`RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 111. Received 112`
dustinbolton commented 4 years ago

Having the same RangeError issue here.