primus / binary-pack

A module to package both browser and node versions of @ericz's binarypack
MIT License
5 stars 2 forks source link

RangeError: Maximum call stack size exceeded #27

Open akahmet opened 6 years ago

akahmet commented 6 years ago

RangeError: Maximum call stack size exceeded at BinaryPack.Unpacker.readInt64 (/usr/src/server/node_modules/binarypack/lib/binarypack.js:115:51)

File need an update as stated below.

BinaryPack.Unpacker.prototype.readUInt64 = function(){
  var bytes = this.cursor.slice(8).buffer;
  return ((((((bytes[0]  * 256 +
               bytes[1]) * 256 +
               bytes[2]) * 256 +
               bytes[3]) * 256 +
               bytes[4]) * 256 +
               bytes[5]) * 256 +
               bytes[6]) * 256 +
               bytes[7];
}

BinaryPack.Unpacker.prototype.readInt64 = function(){
  var uint64 = this.readUInt64();
  console.log(uint64, 'log');
  return (uint64 < Math.pow(2, 63) ) ? uint64 : uint64 - Math.pow(2, 64);
}
lpinca commented 6 years ago

This module relies on https://github.com/binaryjs/node-binarypack which is no longer maintained. I would use https://github.com/primus/primus-msgpack instead. The added benefit is that primus-msgpack is faster.