Skip to content

Decoding of serialized object fails when there are about 70,000 keys or more #147

@rotemdan

Description

@rotemdan

System info

  • msgpackr version: 1.11.0
  • node version: v22.9.0
  • OS: Windows 11 x64

Reduced test case

import { encode, decode } from 'msgpackr'

export function test() {
	let obj: any = {}

	for (let i = 0; i < 70000; i++) {
		obj['x' + i] = true
	}

	const encoded = encode(obj)

	const decoded = decode(encoded)

	console.log(decoded)
}

test()

decode(encoded) fails with error:

Error: Data read, but end of buffer not reached 
{"x0":true,"x1":true,"x2":true,"x3":true,"x4":true,"x5":true,"x6":true,"x7":true,"x8":true,"x9":true

If reducing loop to 60,000 iterations (object keys), there is no failure on decoding, meaning the issue is likely related to the size of the object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions