[error] [function:ad5d176.511d5e8] RangeError: Maximum call stack size exceeded

Hello Everyone,

I am working with modbus-RTU. It is working fine but after some time I am getting this error ( [error] [function:ad5d176.511d5e8] RangeError: Maximum call stack size exceeded).
Please help me out to resolve this error.

Here is my flow:

[{"id":"7489e0d3.23886","type":"tab","label":"Flow 1","disabled":true,"info":""},{"id":"a2740d85.e667b","type":"function","z":"7489e0d3.23886","name":"Power","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nmsg.payload = parseFloat(fltView[0].toFixed(1));\nmsg.topic = \"power\";\n\nnode.status({fill:\"blue\",shape:\"ring\",text:msg.topic + \":\" + msg.payload});    \n\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":1020,"wires":[[]]},{"id":"afa1b96.312f148","type":"function","z":"7489e0d3.23886","name":"Frequency","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nmsg.payload = parseFloat(fltView[0].toFixed(1));\nmsg.topic = \"frequency\";\n\n//node.status({fill:\"blue\",shape:\"ring\",text:msg.topic + \":\" + msg.payload});    \n\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":560,"wires":[["228b8c91.748154"]]},{"id":"20f32d11.d9eb52","type":"function","z":"7489e0d3.23886","name":"Energy","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nmsg.payload = parseFloat(fltView[0].toFixed(2));\nmsg.topic = \"energy\";\n\nnode.status({fill:\"blue\",shape:\"ring\",text:msg.topic + \":\" + msg.payload});    \n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":720,"wires":[["77f5d715.5ef478"]]},{"id":"ff911fab.30e72","type":"function","z":"7489e0d3.23886","name":"Current_1","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nmsg.payload = parseFloat(fltView[0].toFixed(1));\nmsg.topic = \"current_1\";\n\nnode.status({fill:\"blue\",shape:\"ring\",text:msg.topic + \":\" + msg.payload});    \n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":300,"wires":[["b508fa55.af26a8"]]},{"id":"ac9b20e8.46608","type":"modbus-flex-getter","z":"7489e0d3.23886","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":390,"y":80,"wires":[["94bec963.94a238"],[]]},{"id":"89b14bb5.ed0958","type":"function","z":"7489e0d3.23886","name":"","func":"msg.payload = { \n    'value': msg.payload,\n    'fc': 4,\n    'unitid': 7,\n    'address': 0 ,\n    'quantity': 2\n    };\n    return msg;\n","outputs":1,"noerr":0,"x":177,"y":77,"wires":[["ac9b20e8.46608","62ba117.761bef"]]},{"id":"94bec963.94a238","type":"function","z":"7489e0d3.23886","name":"Voltage_1","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nmsg.payload = parseFloat(fltView[0].toFixed(1));\nmsg.topic = \"voltage_1\";\n\nnode.status({fill:\"blue\",shape:\"ring\",text:msg.topic + \":\" + msg.payload});    \n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":80,"wires":[["dbdda826.ec6eb8"]]},{"id":"cf1e65a4.54b538","type":"modbus-flex-getter","z":"7489e0d3.23886","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":390,"y":160,"wires":[["7712c822.e073d8"],[]]},{"id":"a9275de5.66922","type":"modbus-flex-getter","z":"7489e0d3.23886","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":390,"y":240,"wires":[["fa070c48.6be6"],[]]},{"id":"7712c822.e073d8","type":"function","z":"7489e0d3.23886","name":"Voltage_2","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nmsg.payload = parseFloat(fltView[0].toFixed(1));\nmsg.topic = \"voltage_2\";\n\nnode.status({fill:\"blue\",shape:\"ring\",text:msg.topic + \":\" + msg.payload});    \n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":160,"wires":[["516dcc0.2fa5434"]]},{"id":"fa070c48.6be6","type":"function","z":"7489e0d3.23886","name":"Voltage_2","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nmsg.payload = parseFloat(fltView[0].toFixed(1));\nmsg.topic = \"voltage_2\";\n\nnode.status({fill:\"blue\",shape:\"ring\",text:msg.topic + \":\" + msg.payload});    \n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":240,"wires":[["5f1b8704.421e68"]]},{"id":"62ba117.761bef","type":"function","z":"7489e0d3.23886","name":"","func":"msg.payload = { \n    'value': msg.payload,\n    'fc': 4,\n    'unitid': 7,\n    'address': 2 ,\n    'quantity': 2\n    };\n    return msg;\n","outputs":1,"noerr":0,"x":177,"y":157,"wires":[["cf1e65a4.54b538","d6efe055.af765"]]},{"id":"d6efe055.af765","type":"function","z":"7489e0d3.23886","name":"","func":"msg.payload = { \n    'value': msg.payload,\n    'fc': 4,\n    'unitid': 7,\n    'address': 4 ,\n    'quantity': 2\n    };\n    return msg;\n","outputs":1,"noerr":0,"x":177,"y":237,"wires":[["a9275de5.66922","acf7bf6b.01b18"]]},{"id":"bf2580e0.042e1","type":"inject","z":"7489e0d3.23886","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":87,"y":37,"wires":[["89b14bb5.ed0958"]]},{"id":"3b5eaea5.ee9712","type":"modbus-flex-getter","z":"7489e0d3.23886","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":390,"y":300,"wires":[["ff911fab.30e72"],[]]},{"id":"ec85b8d2.112378","type":"modbus-flex-getter","z":"7489e0d3.23886","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":390,"y":380,"wires":[["77399ad0.441264"],[]]},{"id":"fc618c57.79825","type":"modbus-flex-getter","z":"7489e0d3.23886","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":390,"y":460,"wires":[["6e997dcc.13c444"],[]]},{"id":"77399ad0.441264","type":"function","z":"7489e0d3.23886","name":"Current_2","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nmsg.payload = parseFloat(fltView[0].toFixed(1));\nmsg.topic = \"current_2\";\n\nnode.status({fill:\"blue\",shape:\"ring\",text:msg.topic + \":\" + msg.payload});    \n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":380,"wires":[["3746326e.1b1d2e"]]},{"id":"6e997dcc.13c444","type":"function","z":"7489e0d3.23886","name":"Current_3","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nmsg.payload = parseFloat(fltView[0].toFixed(1));\nmsg.topic = \"current_3\";\n\nnode.status({fill:\"blue\",shape:\"ring\",text:msg.topic + \":\" + msg.payload});    \n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":460,"wires":[["49e8ed98.02e014"]]},{"id":"acf7bf6b.01b18","type":"function","z":"7489e0d3.23886","name":"","func":"msg.payload = { \n    'value': msg.payload,\n    'fc': 4,\n    'unitid': 7,\n    'address': 6 ,\n    'quantity': 2\n    };\n    return msg;\n","outputs":1,"noerr":0,"x":180,"y":300,"wires":[["3b5eaea5.ee9712","618b0148.69baf"]]},{"id":"618b0148.69baf","type":"function","z":"7489e0d3.23886","name":"","func":"msg.payload = { \n    'value': msg.payload,\n    'fc': 4,\n    'unitid': 7,\n    'address': 8 ,\n    'quantity': 2\n    };\n    return msg;\n","outputs":1,"noerr":0,"x":180,"y":380,"wires":[["ec85b8d2.112378","de3f2c26.a9aa2"]]},{"id":"de3f2c26.a9aa2","type":"function","z":"7489e0d3.23886","name":"","func":"msg.payload = { \n    'value': msg.payload,\n    'fc': 4,\n    'unitid': 7,\n    'address': 10 ,\n    'quantity': 2\n    };\n    return msg;\n","outputs":1,"noerr":0,"x":180,"y":460,"wires":[["fc618c57.79825","37af22ce.55590e"]]},{"id":"8f56a262.364b3","type":"modbus-flex-getter","z":"7489e0d3.23886","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":390,"y":560,"wires":[["afa1b96.312f148"],[]]},{"id":"37af22ce.55590e","type":"function","z":"7489e0d3.23886","name":"","func":"msg.payload = { \n    'value': msg.payload,\n    'fc': 4,\n    'unitid': 7,\n    'address': 70 ,\n    'quantity': 2\n    };\n    return msg;\n","outputs":1,"noerr":0,"x":200,"y":560,"wires":[["8f56a262.364b3","df15506b.d886a"]]},{"id":"2b5d5b28.1db294","type":"inject","z":"7489e0d3.23886","d":true,"name":"","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":70,"y":560,"wires":[["37af22ce.55590e"]]},{"id":"b4e7f950.763598","type":"function","z":"7489e0d3.23886","name":"","func":"context.data=context.data || {};\nswitch(msg.topic){\n    case \"task1\":\n        context.data.task1=msg.payload;\n        msg=null;\n        break;\n    case \"task2\":\n        context.data.task2=msg.payload;\n        msg=null;\n        break;\n    case \"task3\":\n        context.data.task3=msg.payload;\n        msg=null;\n        break;\n}\nif(context.data.task1 != null && context.data.task2 != null && context.data.task3 != null){\n    msg={\n        \"C1\":context.data.task1,\n        \"C2\":context.data.task2,\n        \"C3\":context.data.task3\n    }\n    context.data=null;\n    return {payload:msg};\n}","outputs":1,"noerr":0,"x":900,"y":380,"wires":[["b358481e.398958"]]},{"id":"b508fa55.af26a8","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"task1\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":300,"wires":[["b4e7f950.763598"]]},{"id":"3746326e.1b1d2e","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"task2\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":380,"wires":[["b4e7f950.763598"]]},{"id":"49e8ed98.02e014","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"task3\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":460,"wires":[["b4e7f950.763598"]]},{"id":"81510800.7e7d78","type":"function","z":"7489e0d3.23886","name":"","func":"context.data=context.data || {};\nswitch(msg.topic){\n    case \"task1\":\n        context.data.task1=msg.payload;\n        msg=null;\n        break;\n    case \"task2\":\n        context.data.task2=msg.payload;\n        msg=null;\n        break;\n    case \"task3\":\n        context.data.task3=msg.payload;\n        msg=null;\n        break;\n}\nif(context.data.task1 != null && context.data.task2 != null && context.data.task3 != null){\n    msg={\n        \"V1\":context.data.task1,\n        \"V2\":context.data.task2,\n        \"V3\":context.data.task3\n    }\n    context.data=null;\n    return {payload:msg};\n}","outputs":1,"noerr":0,"x":900,"y":140,"wires":[["ca5bb13e.81248"]]},{"id":"dbdda826.ec6eb8","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"task1\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":80,"wires":[["81510800.7e7d78"]]},{"id":"516dcc0.2fa5434","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"task2\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":160,"wires":[["81510800.7e7d78"]]},{"id":"5f1b8704.421e68","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"task3\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":240,"wires":[["81510800.7e7d78"]]},{"id":"b5d56fdf.fa5d7","type":"modbus-flex-getter","z":"7489e0d3.23886","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":390,"y":720,"wires":[["20f32d11.d9eb52"],[]]},{"id":"df15506b.d886a","type":"function","z":"7489e0d3.23886","name":"","func":"msg.payload = { \n    'value': msg.payload,\n    'fc': 4,\n    'unitid': 7,\n    'address': 72 ,\n    'quantity': 2\n    };\n    return msg;\n","outputs":1,"noerr":0,"x":200,"y":720,"wires":[["b5d56fdf.fa5d7","8ee6c15d.d9d22"]]},{"id":"228b8c91.748154","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"freq\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":560,"wires":[["88f81fe4.6ebcb","b15d5326.1cde8"]]},{"id":"77f5d715.5ef478","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"energy\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":720,"wires":[["88f81fe4.6ebcb"]]},{"id":"ca5bb13e.81248","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"volt\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":1060,"y":140,"wires":[["88f81fe4.6ebcb"]]},{"id":"b358481e.398958","type":"function","z":"7489e0d3.23886","name":"","func":"var val=msg.payload;\nmsg={\n    \"topic\":\"curr\",\n    \"payload\":val\n}\nreturn msg;","outputs":1,"noerr":0,"x":1060,"y":380,"wires":[["88f81fe4.6ebcb"]]},{"id":"88f81fe4.6ebcb","type":"function","z":"7489e0d3.23886","name":"","func":"context.data=context.data || {};\nswitch(msg.topic){\n    case \"volt\":\n        context.data.volt=msg.payload;\n        msg=null;\n        break;\n    case \"curr\":\n        context.data.curr=msg.payload;\n        msg=null;\n        break;\n    case \"freq\":\n        context.data.freq=msg.payload;\n        msg=null;\n        break;\n    case \"energy\":\n        context.data.energy=msg.payload;\n        msg=null;\n        break;\n}\nif(context.data.volt != null && context.data.curr != null && context.data.freq != null && context.data.energy != null ){\n    msg={\n        \"Device\":\"Energy Meter\",\n        \"Device_ID\":8,\n        \"Voltage\":context.data.volt,\n        \"Current\":context.data.curr,\n        \"Frequency\":context.data.freq,\n        \"Energy\":context.data.energy\n    }\n    context.data=null;\n    return {payload:msg};\n}","outputs":1,"noerr":0,"x":1360,"y":460,"wires":[["1c5a2050.d87a6","3fe07f57.4434d"]]},{"id":"1c5a2050.d87a6","type":"debug","z":"7489e0d3.23886","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1550,"y":540,"wires":[]},{"id":"3fe07f57.4434d","type":"mqtt out","z":"7489e0d3.23886","d":true,"name":"","topic":"devices/875878/messages","qos":"","retain":"","broker":"fa7e2623.3eda88","x":1580,"y":340,"wires":[]},{"id":"b15d5326.1cde8","type":"debug","z":"7489e0d3.23886","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1310,"y":580,"wires":[]},{"id":"8ee6c15d.d9d22","type":"delay","z":"7489e0d3.23886","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":100,"y":340,"wires":[["89b14bb5.ed0958"]]},{"id":"fa7e2623.3eda88","type":"mqtt-broker","name":"","broker":"192.168.1.17","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

I dont think this part of your overall flows is your issue. I dont see any loops to cause a stack exceeded exception. You possibly have a loop somewhere else (e.g. subscribing to an MQTT topic that you later update ~ causing a feedback loop)

As for your flow - wow!

I would recommend you look into using the buffer-parser.

Thank you,
My issue is got resolved.

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