ronomon / hash-table

Fast, reliable cuckoo hash table for Node.js.
MIT License
301 stars 12 forks source link

Error: BUFFER_MAX must be at most 4294967295 with node 16.x #6

Closed hnakamur closed 2 years ago

hnakamur commented 3 years ago

I got this error when I was trying the benchmark at https://github.com/coilhq/tigerbeetle/tree/466fb090bde0203fae396542a1865f16d97a8bd2/demos/hash_table#nodejs

I looked at the Node.js document and found out the value buffer.kMaxLength in Node.js 16.x is different from one in Node.js 14.x.

buffer.kMaxLength

An alias for buffer.constants.MAX_LENGTH.

Node.js 14.x buffer.constants.MAX_LENGTH

On 64-bit architectures, this value currently is 2^32 - 1 (~4GB).

Node.js 16.x buffer.constants.MAX_LENGTH

On 64-bit architectures, this value currently is 2^32 (about 4 GB).

The assertion error does not happen when I replace Math.pow(2, 32) - 1 at https://github.com/ronomon/hash-table/blob/a951174315bb6980b85a31e46f144d7ca2c1cd4b/index.js#L228 with Math.pow(2, 32).

jorangreef commented 2 years ago

Thanks @hnakamur !

It should be fixed in @ronomon/hash-table@2.0.8, if you reinstall the module.