Skip to content

node-red-node-cbor cannot handle BigInt #1101

@matthias-heinisch

Description

@matthias-heinisch

Which node are you reporting and issue on?

node-red-node-cbor

What are the steps to reproduce?

send a timestamp as integer to decode - the decoder exits with the error message "Bad Decode"

What happens?

the node-red-node-cbor plugin serializes the decoded result with JSON:

node.status({text:l +" b->o "+ JSON.stringify(value).length});

As JSON does not support BigInt, this creates an error message when you are decoding a timestamp for example.

What did you expect to happen?

  1. The decoder should decode correctly sent buffers without error message.
  2. The error message should correspond to the actual error.

Proposed solution

  1. I propose to add a replacer function and convert BigInt and other unsupported formats.
  2. The error message "not a cbor buffer" is not always correct. I would prefer to use the actual error message.

Additionally, cbor-x library is out of date and should be updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions