No dubug message in sidebar when using readBigInt64BE


I discovered an interesting behavior in node red.
I'm using the node-red-contrib-modbus pallete and its modbus-server node to read data from a modbus tcp. Debugging its output with the debug node works fine. When adding a function debugging keeps working until I add the following command code line:

var int1 = bufint.readBigInt64BE(0);

the method shown here refers to this package:

And the interesting thing is. Although the debug node is not showing anything the following code is writing the right result to the console. So node red keeps working.


My test flow for testing:

[{"id":"94000c64.5b6b5","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"b93a9741.e0d148","type":"modbus-server","z":"94000c64.5b6b5","name":"","logEnabled":false,"hostname":"","serverPort":10502,"responseDelay":100,"delayUnit":"ms","coilsBufferSize":"0","holdingBufferSize":"5","inputBufferSize":"1","discreteBufferSize":"0","showErrors":false,"x":600,"y":160,"wires":[["a0675782.ca5198"],[],[],[],[]]},{"id":"dceda277.20686","type":"function","z":"94000c64.5b6b5","name":"","func":"msg.payload = { 'value': msg.payload, \n'register': 'holding', \n'address': 2, \n'disableMsgOutput' : 0 }; \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":160,"wires":[["b93a9741.e0d148"]]},{"id":"e7bd997.b998968","type":"inject","z":"94000c64.5b6b5","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2.1","payloadType":"num","x":110,"y":160,"wires":[["dceda277.20686"]]},{"id":"a0675782.ca5198","type":"function","z":"94000c64.5b6b5","name":"","func":"var buf = msg.payload;\nvar bufint = buf.subarray(0,8);\nvar int1 = bufint.readBigInt64BE(0);\nvar msg1 = { payload : int1 };\nconsole.log(msg1)\nreturn msg1;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":860,"y":140,"wires":[["e4a42523.50cee8"]]},{"id":"e4a42523.50cee8","type":"debug","z":"94000c64.5b6b5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":140,"wires":[]}]

Thank you in advance for your help!

This is a known issue.

The problem is with JSON.stringify (or to be more accurate the issue is with BigInt being introduced after the JSON specification). If I am not mistaken, JSON.stringify is used to serialise debug messages for sending from node-red server to client & thus cannot handle BigInt data type.

Demo of node.js trying to stringify a bigInt of 1 (1n is a BigInt with value of 1)...

Here is a little light reading on the subject.

Thank you a lot for this fast and detailed answer! It works fine indeed with the 32 bit conversion. I'll think about whether 64 bits are really necessary for my application.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.