flatbuffers
flatbuffers copied to clipboard
Javascript flexbuffers.toObject() small value change causes TypeError: Cannot mix BigInt
Environment
flatbuffers v2.0.4 node v16.13.0 Debian GNU/Linux 11 (bullseye) tsc version 4.5.2
Repro
This is in Typescript:
const flex_in = {
test_number: 72.6 // Change this to 72.5 and the error does not occur.
};
const flex_buf = flexbuffers.encode(flex_in, 1, false, false, false);
flexbuffers.toObject(flex_buf.buffer); // *** Error ***
TypeError: Cannot mix BigInt and other types, use explicit conversions
at keyForIndex (/home/Dev/test_proj/node_modules/flatbuffers/js/flexbuffers/reference-util.js:119:43)
at Reference.toObject (/home/Dev/test_proj/node_modules/flatbuffers/js/flexbuffers/reference.js:166:60)
at Proxy.toObject (/home/Dev/test_proj/node_modules/flatbuffers/js/flexbuffers.js:14:49)
at Object.<anonymous> (/home/Dev/test_proj/src/test/test_buffers.js:73:13)
at Generator.next (<anonymous>)
If I change test_number
to 72.5
it works fine.
I'm not sure what the size
(2nd) parameter to encode()
should be, but the same thing happens if I call flexbuffers.encode(flex_in)
with no other parameters.
@mzaks
@mzaks Can you take a look?
Bug is fixed in the PR #7434 Sorry for the delay. Seems like I missed the first mention in 2021.