cbor-x
cbor-x copied to clipboard
Error: Unknown type function
Hi again,
There is a strange error when I'm using CBOR. But the error is not consistent and I can't reproduce it in my env, only on Github Actions CI.
Do you have an idea what does Unknown type function
mean?
[2021-05-18T18:03:23.335Z] WARN node2/TRANSPORTER: Invalid incoming GOSSIP_REQ packet. Error: Unknown type function
at encode (/home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1188:11)
at /home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1224:6
at encode (/home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1096:7)
at /home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1224:6
at encode (/home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1096:7)
at /home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1224:6
at encode (/home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1096:7)
at encode (/home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1105:8)
at /home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1224:6
at encode (/home/runner/work/moleculer/moleculer/node_modules/cbor-x/dist/node.cjs:1096:7)
I'm trying to isolate the problem and get more information.
It means that an object that is being serialized included an enumerable property that has a method/function value. Do you suppose that maybe an assertion library could be adding properties/methods to the objects?
I am certainly open to suggestions for how to handle function values (could alternately serialize to a string, or undefined, maybe driven by an option/flag).
Ahh, then I check the payload properties why it contains Function
.
By the way, I suggest just simply skip the Function
as other serializers do. Besides CBOR, I'm testing MsgPack, Notepack, Protobuf, Avro, Thrift serializers as well, and all of them just skip the functions.
By the way, you are right, sometimes the payload contains handler functions.