[BUG] large array + contains Chinese characters + `{bundleStrings: true}` option will cause decoding error
panmenghan opened this issue · comments
reproduction code:
import {Packr, Unpackr} from 'msgpackr'
const MSGPACK_OPTIONS = {bundleStrings: true}
const item = {
message: '你好你好你好你好你好你好你好你好你好', // some Chinese characters
}
function main() {
testSize(100)
testSize(1000)
testSize(10000) // Error: Data read, but end of buffer not reached
}
function testSize(size) {
const list = []
for (let i = 0; i < size; i++) {
list.push({...item})
}
const packer = new Packr(MSGPACK_OPTIONS)
const unpacker = new Unpackr(MSGPACK_OPTIONS)
const encoded = packer.pack(list)
const decoded = unpacker.unpack(encoded)
console.log('size', size, 'ok')
}
main()
I also see the 'Unexpected end of MessagePack data' error when decoding real json data.
This should be fixed in 1.8.4.
It works. thanks.