"Error: ArrayBuffer(2) not defined"

312 views
Skip to first unread message

Peter W

unread,
Jan 22, 2016, 2:56:36 AM1/22/16
to Node-RED
Hi,

just a quick NOOB question: why doesn't 

var buffer = new ArrayBuffer(2);

work in a node-red flow?

It throws a 

Reference error: ArrayBuffer is not defined ...

In standard node.js no problem ..

Many thanks - Peter. 

Dave C-J

unread,
Jan 22, 2016, 3:53:35 AM1/22/16
to node...@googlegroups.com
I'm guessing this is on node.js v0.10.x ?
There must be a different implementation of the vm sandbox at that version. By default we do allow the basic js functions in, though we did have to add Buffer. 
Testing the simple flow below does indeed show the problem using node.js v0.10 but works fine on node.js v0.12 and above...

[{"id":"bb7bd143.44843","type":"inject","z":"3812a366.c7ed5c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":160,"y":540,"wires":[["8635a315.79ca6"]]},{"id":"cac516c3.353ae8","type":"debug","z":"3812a366.c7ed5c","name":"","active":true,"console":"false","complete":"false","x":500,"y":540,"wires":[]},{"id":"8635a315.79ca6","type":"function","z":"3812a366.c7ed5c","name":"","func":"var buf = new ArrayBuffer(2);\nbuf[0] = \"A\";\nbuf[1] = \"B\";\nmsg.payload = JSON.stringify(buf);\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":540,"wires":[["cac516c3.353ae8"]]}]

Peter W

unread,
Jan 22, 2016, 5:52:15 AM1/22/16
to Node-RED
Thank you!

Indeed on v0.10.38 on Raspberry Pi Zero Raspbian Jessie. Will follow your path and try to get node.js updated ... 

Dave C-J

unread,
Jan 22, 2016, 10:18:02 AM1/22/16
to node...@googlegroups.com
Iff you really need ArrayBuffer then yes...  As I said we have the default node.js Buffer capability in there.

Peter W

unread,
Jan 24, 2016, 3:12:32 AM1/24/16
to Node-RED
good news:
  • manual upgrade on Raspberry Pi Zero Jessie to node.js v0.12.6 and node-red v0.13.1 worked
  • ArrayBuffer now also works
Thanks again,
Peter.
Reply all
Reply to author
Forward
0 new messages