Skip to content

Error when decoding data encoded with bundleStrings: true #121

@Kit-p

Description

@Kit-p

Summary

When all the keys and values are strings of length smaller than 4, the encoded data cannot be decoded successfully with the following error.

Uncaught Error: Data read, but end of buffer not reached
    at checkedRead (./node_modules/cbor-x/dist/node.cjs:229:10)
    at Encoder.decode (./node_modules/cbor-x/dist/node.cjs:156:12)

How to reproduce

const { Encoder } = require('cbor-x');
const encoder = new Encoder({ bundleStrings: true });

const data = { abc: '<=3' };
const buf = encoder.encode(data);
encoder.decode(buf); // <-- this will produce the above error

Environment

Node.js: 22.12.0
cbor-x: 1.6.0

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