TypeError: done is not a function

I performed a new install of Raspian Buster and Node-RED yesterday. Everything went well with the installation, or so I thought. I am using the same Pi Zero W hardware for testing.

I import my flow from the SD card that has the same system I built last month. Node-red works fine on that SD card. All my hardware responds the way it should, relays operate and LEDs flash.

On the new installation, none of the hardware works. Node red is apparently not handling the MQTT messages.

Old system that works: v0.20.7 - dashboard: node-red-dashboard v2.15.5 update to 2.17.0
New system doesn't work v0.20.8 - dashboard: node-red-dashboard v2.16.3 update to 2.17.0
Mosquitto broker is version 1.5.7 on both SD cards.

When I click a button on the web interface of the non-working system, I get this message:
10/3/2019, 2:42:42 PMnode: Confirmfunction : (error)
"TypeError: done is not a function"
and nothing happens on the hardware.

When I click the same button on the working SD card, I get this message:
10/3/2019, 3:10:46 PMnode: 45743d9b.5f003c
esp32/door/button : msg : Object
object
payload: "pressed"
topic: "esp32/door/button"
socketid: "zGa5P44-ov2HAzOFAAAA"
msgid: "306bf5da.56480a"
and the relays click and the LEDs flash.

Has anyone seen this issue with their system? I've tried everything I can think of with no fix.

What is the code in your confirm function?

A function node with this code:var payload = msg.payload; if(payload == "OK") { msg.payload = "pressed"; msg.topic = "esp32/door/button"; } else { msg.payload = null; // cancel } return msg;

It works fine with the older version of Node Red

The confirm function is driven by an OK/Cancel Edit notification node. That is what actually drives the confirm function.

I just ran a test. I disconnected the output of the confirm function from the Debug node. When I click the button in the web interface, I still get the TypeError: done is not a function. I don't know how it is getting to the debug window with no Debug node connected.

Something apparently changed with the function nodes between v0.20.7 and v0.20.8. I have a color function that changes the color of the buttons when the state of the switches change. The function node for the color change is also generating the same error message.

10/3/2019, 7:55:45 PMnode: Color Statefunction : (error)
"TypeError: done is not a function"

Can you provide your flow

If you performed a new installation yesterday, how did you do it?
If you followed the install script as per the docs you would have ended up with Node-RED v1

What version of nodejs are you using?

I tried 3 times to use the script but it failed all 3 times. I don't remember where it failed but it would hang and generate kernel error messages. I finally used apt-get to install it. The script worked last month when I used it for the SD card that works.

nodejs v10.15.2 on both systems.

Flow attached.

[{"id":"f1d0ee65.185938","type":"tab","label":"ESP32 Flow","disabled":false,"info":"> test"},{"id":"ff641b2b.d4e248","type":"ui_button","z":"f1d0ee65.185938","name":"Status Button","group":"6189c2aa.ecad8c","order":3,"width":"3","height":"1","passthru":false,"label":"Status ?","tooltip":"Displays current door position","color":"","bgcolor":"{{background}}","icon":"","payload":"","payloadType":"str","topic":"","x":740,"y":100,"wires":[[]]},{"id":"876ed58d.9cae28","type":"mqtt out","z":"f1d0ee65.185938","name":"Publish Node","topic":"","qos":"2","retain":"false","broker":"e563d5b9.14f0c8","x":750,"y":180,"wires":[]},{"id":"1f84dcb9.232fc3","type":"ui_button","z":"f1d0ee65.185938","name":"Door Button","group":"6189c2aa.ecad8c","order":6,"width":"3","height":"1","passthru":false,"label":"Operate","tooltip":"","color":"","bgcolor":"{{background}}","icon":"","payload":"pressed","payloadType":"str","topic":"esp32/door/button","x":330,"y":120,"wires":[["b5a21d5b.1dcd38"]]},{"id":"513c9c66.ec1c8c","type":"ui_text","z":"f1d0ee65.185938","group":"6189c2aa.ecad8c","order":1,"width":"0","height":"0","name":"Door Status","label":"Door Status","format":"{{msg.payload}}","layout":"row-spread","x":530,"y":40,"wires":[]},{"id":"54d0980a.d015d8","type":"mqtt in","z":"f1d0ee65.185938","name":"Return Status","topic":"esp32/door/stat-return","qos":"2","datatype":"utf8","broker":"e563d5b9.14f0c8","x":330,"y":40,"wires":[["513c9c66.ec1c8c","2fa42f9c.e02d48"]]},{"id":"4a7113d2.b9620c","type":"mqtt in","z":"f1d0ee65.185938","name":"Beam","topic":"esp32/door/beam","qos":"2","datatype":"auto","broker":"e563d5b9.14f0c8","x":310,"y":320,"wires":[["5d30d4c1.1f58d4","51432b30.94f5f4"]]},{"id":"5d30d4c1.1f58d4","type":"change","z":"f1d0ee65.185938","name":"Beam State","rules":[{"t":"change","p":"payload","pt":"msg","from":"broken","fromt":"str","to":"1","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"present","fromt":"str","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":340,"wires":[["f4b7117f.bd04a8"]]},{"id":"2fa42f9c.e02d48","type":"function","z":"f1d0ee65.185938","name":"Color State","func":"if(msg.payload == \"Door is open\") {\n    msg.background = \"RED\";\n}\nif(msg.payload == \"Door is closed\") {\n    msg.background = \"GREEN\";\n}\nif(msg.payload == \"A door switch is stuck closed\") {\n    msg.background = \"#ffa100\";\n}\nif(msg.payload == \"Door is stuck\") {\n    msg.background = \"#ffa100\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":100,"wires":[["ff641b2b.d4e248"]]},{"id":"b5a21d5b.1dcd38","type":"ui_toast","z":"f1d0ee65.185938","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"OK","cancel":"Cancel","topic":"Operate Door?","name":"OK/Cancel","x":350,"y":180,"wires":[["d2203026.65547"]]},{"id":"d2203026.65547","type":"function","z":"f1d0ee65.185938","name":"Confirm","func":"var payload = msg.payload;\nif(payload == \"OK\") {\n    msg.payload = \"pressed\";\n    msg.topic = \"esp32/door/button\";\n}\nelse  {\n    msg.payload = null; // cancel\n}\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":160,"wires":[["876ed58d.9cae28"]]},{"id":"128abdd8.be9b6a","type":"e-mail","z":"f1d0ee65.185938","server":"mymailserver.com","port":"3585","secure":false,"tls":true,"name":"tester@zoogle.com","dname":"Mail Out","x":760,"y":300,"wires":[]},{"id":"51432b30.94f5f4","type":"change","z":"f1d0ee65.185938","name":"Msg Mod","rules":[{"t":"change","p":"payload","pt":"msg","from":"broken","fromt":"str","to":"Garage door has been opened. Burglary in progress.","tot":"str"},{"t":"change","p":"topic","pt":"msg","from":"esp32/door/beam","fromt":"str","to":"Door Alert","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"present","fromt":"str","to":"Garage door has been closed.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":280,"wires":[["f4b7117f.bd04a8"]]},{"id":"8d18432a.5e6e28","type":"change","z":"f1d0ee65.185938","name":"Blink Flow","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"false","tot":"bool"},{"t":"set","p":"Blink","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":580,"wires":[[]]},{"id":"e41d53f9.6edc6","type":"inject","z":"f1d0ee65.185938","name":"Every 0.45 sec","topic":"","payload":"Blink","payloadType":"flow","repeat":"0.45","crontab":"","once":false,"onceDelay":0.1,"x":340,"y":640,"wires":[["2259bde5.3500a2"]]},{"id":"9823a5b.a89d258","type":"inject","z":"f1d0ee65.185938","name":"Every 1.15 sec","topic":"","payload":"Blink","payloadType":"flow","repeat":"1.15","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":700,"wires":[["ea0b164d.85a6c"]]},{"id":"2259bde5.3500a2","type":"switch","z":"f1d0ee65.185938","name":"Blink == true","property":"Blink","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":640,"wires":[["c2150d16.7bb888"]]},{"id":"ea0b164d.85a6c","type":"switch","z":"f1d0ee65.185938","name":"Blink == false","property":"Blink","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":520,"y":700,"wires":[["305d859f.596cda"]]},{"id":"c2150d16.7bb888","type":"trigger","z":"f1d0ee65.185938","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"200","extend":false,"units":"ms","reset":"","bytopic":"all","name":"Fast Blink","x":720,"y":580,"wires":[["34905f9.06118a"]]},{"id":"305d859f.596cda","type":"trigger","z":"f1d0ee65.185938","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"600","extend":false,"units":"ms","reset":"","bytopic":"all","name":"Slow Blink","x":710,"y":700,"wires":[["34905f9.06118a"]]},{"id":"34905f9.06118a","type":"rpi-gpio out","z":"f1d0ee65.185938","name":"LED Blink","pin":"32","set":"","level":"0","freq":"","out":"out","x":760,"y":640,"wires":[]},{"id":"354fe11.d87389e","type":"comment","z":"f1d0ee65.185938","name":"","info":"Door Armed?, Blink Flow, Every 0.45 sec, Blink ==\ntrue, Fast Blink, Every 1.15 sec, Blink == false,\nSlow Blink, and LED Blink nodes are used to control\nthe flash rate of the Raspberry Pi panel LED. These\nnodes only respond to incoming arm messages from\nthe ESP32. If the arm button on the Raspberry Pi\nis pressed, it sends a message to the ESP32 to arm\nor disarm the system. The ESP32 takes the requested\naction and sends the result back to these nodes.\nThe Raspberry Pi receives the result, beeps the\ncorrect number or beeps, and sets the LED blink\ntime to the correct rate.\n\nDoor Armed?, Set Beep, One Beep, Delay 0.4s, One\nof Two, Two of Two, Alarm Beep, and Beep/Alarm nodes\nall control the arm/disarm beeps at the Raspberry Pi\n\nThe Beam, Beam State, and Beep/Alarm nodes set\noff the alarm buzzer on the Raspberry Pi when the\nsystem is armed and the garage door beam is broken.\n\nThe Beam, Msg Mod, and Mail Out nodes send a text\nmessage to the cell phone when the system is armed\nand the garage door beam is broken.\n\nThe Pi Arm Button, Button Pressed, and Publish Node\nnodes send a message to the ESP32 when the arm\nbutton is pressed on the Raspberry Pi. Each press\nof the button either arms or disarms the system.\nNote: See the very first note above for more\ndetails on the Pi LED flash and beep rate.\n\nDoor Button, OK/Cancel, Confirm, and Publish Node\nnodes control the door opening and closing from the\nweb interface page.\n\nReturn Status, Door Status, Color Status, and Status\nButton nodes update the status bar color and text\nmessage box icons on the web interface page.\n\n\nRaspberry Pi GPIO Assignments:\n32 - GPIO12 - LED blink\n35 - GPIO19 - Pi Arm Button\n37 - GPIO26 - Arm and alarm beeps\n","x":760,"y":520,"wires":[]},{"id":"fdb35ab1.88d5b","type":"switch","z":"f1d0ee65.185938","name":"Set Beep","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":320,"y":500,"wires":[["afb87b23.c38d08","f9ea2120.ce2ff8"],["dd9b4d0d.ebbab8"]]},{"id":"f250540f.bc85f8","type":"mqtt in","z":"f1d0ee65.185938","name":"Door Armed?","topic":"esp32/door/blink","qos":"2","datatype":"auto","broker":"e563d5b9.14f0c8","x":330,"y":580,"wires":[["8d18432a.5e6e28","fdb35ab1.88d5b"]]},{"id":"dd9b4d0d.ebbab8","type":"trigger","z":"f1d0ee65.185938","op1":"1","op2":"0","op1type":"num","op2type":"num","duration":"500","extend":false,"units":"ms","reset":"","bytopic":"all","name":"One Beep","x":520,"y":520,"wires":[["f4b7117f.bd04a8"]]},{"id":"f4b7117f.bd04a8","type":"rpi-gpio out","z":"f1d0ee65.185938","name":"Beep/Alarm","pin":"37","set":true,"level":"0","freq":"","out":"out","x":750,"y":400,"wires":[]},{"id":"afb87b23.c38d08","type":"trigger","z":"f1d0ee65.185938","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"200","extend":false,"units":"ms","reset":"","bytopic":"all","name":"One of Two","x":530,"y":460,"wires":[["f4b7117f.bd04a8"]]},{"id":"f9ea2120.ce2ff8","type":"delay","z":"f1d0ee65.185938","name":"","pauseType":"delay","timeout":"0.4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":330,"y":420,"wires":[["bd7df476.0aa86"]]},{"id":"bd7df476.0aa86","type":"trigger","z":"f1d0ee65.185938","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"200","extend":false,"units":"ms","reset":"","bytopic":"all","name":"Two of Two","x":530,"y":400,"wires":[["f4b7117f.bd04a8"]]},{"id":"adc1aaf4.8e2b6","type":"rpi-gpio in","z":"f1d0ee65.185938","name":"Pi Arm Button","pin":"35","intype":"up","debounce":"100","read":false,"x":330,"y":240,"wires":[["918a586b.7736a"]]},{"id":"918a586b.7736a","type":"change","z":"f1d0ee65.185938","name":"Button Pressed","rules":[{"t":"set","p":"topic","pt":"msg","to":"esp32/door/arm","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"on","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":220,"wires":[["876ed58d.9cae28"]]},{"id":"6189c2aa.ecad8c","type":"ui_group","z":"","name":"Garage Door","tab":"1bf0a2b5.1f8845","disp":true,"width":"6","collapse":false},{"id":"e563d5b9.14f0c8","type":"mqtt-broker","z":"","name":"MyPi","broker":"172.16.1.112","port":"1883","clientid":"pi","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"1bf0a2b5.1f8845","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

What script?
Do you mean your flow or the install script?

Yes, the install script. I don't want to run again if it will install v1. If there was a way to install v0.20.7 I would do that and hopefully the problem would disappear.

As for installing v1, I make it a practice to never install new releases of any software until it has been out for a few months. I consider new releases of all software to be Beta regardless of who releases them.

Node-RED uses npm so you can install any version you like.

npm install -g node-red@0.20.8

or even

npm install -g node-red@0.1.0

:rofl:

You could always install using the script which will take care of permissions, additional support libraries etc. And then downgrade using;
npm install -g node-red@0.20.8
as Julian suggests above.

If you do get error messages using the script (as you have said above) then let us know what they are so it can be fixed. It may save you having problems further down the road....

OK, I decided to try it again with the script. I took a new SD care and installed Raspbian Buster. I then tried to install Node-red using the script. It got as far as the Remove old version on node.js and then started to Install Node.js. After a couple of minutes it comes up with this message:

Message from syslogd@Pi-Zero-W at Oct  4 14:19:01 ...
 kernel:[  538.902882] Internal error: Oops: 17 [#1] ARM
  Move global nodes to local
Message from syslogd@Pi-Zero-W at Oct  4 14:19:01 ...
 kernel:[  538.903214] Process kworker/u2:0 (pid: 5, stack limit = 0x1c008a4f)
  Add shortcut commands
Message from syslogd@Pi-Zero-W at Oct  4 14:19:01 ...
 kernel:[  538.903225] Stack: (0xdacffb40 to 0xdad00000)

Message from syslogd@Pi-Zero-W at Oct  4 14:19:01 ...ll.log
 kernel:[  538.903242] fb40: 00000000 da4b8c38 d43c7248 dacffb58 c0117840 dacffd90 00001058 dacffca0

Message from syslogd@Pi-Zero-W at Oct  4 14:19:01 ...
 kernel:[  538.903259] fb60: db0b20d8 00002971 00000000 000017ff dacffca0 0000000d dacffbac dacffb88

Message from syslogd@Pi-Zero-W at Oct  4 14:19:01 ...
 kernel:[  538.903273] fb80: c022226c c0242884 00000000 c01094e0 00001059 dacffc14 0016a859 00000000

Message from syslogd@Pi-Zero-W at Oct  4 14:19:01 ...
 kernel:[  538.903288] fba0: dacffc4c dacffbb0 c0227894 c02221f4 00000800 00000000 c02226fc c011cab4

There about 20 other mesages but there is no need in pasting all of them. The system is now hung and I cannot log into it with another terminal window. There is no activity on the LED indicating SD card access.

My only choice now is to pull the power plug and then reboot the system.

I will try to use "npm install -g node-red@0.20.7". If that installs properly and I import my flow, it should work.

I tried to run "npm install -nod-red@0.20.7" but the Pi told me npm was not installed. I then entered nodejs -v and the Pi said it wasn't installed. So the script was able to successfully uninstall parts of v0.20.8 but since it failed on the re-install, everything was gone.

I logged out of the Pi and unplugged it and plugged it back in so it rebooted. I then tried logging into the Pi but could not. It prompted for the password, I entered it, waited 2 minutes and it never responded. So at this point I knew it was useless to continue.

I formatted the SD card again and re-installed the Raspbian Buster image. I then ran sudo npm install -g node-red@0.20.7 and it was successful. I installed the mosquitto broker and started node-red. It came right up.

I then imported my flow and bingo!! everything works properly. So there is apparently some kind of issue with v0.20.8 that is causing "TypeError: done is not a function" error message. I still have the SD card with v0.20.8. I will continue to play with it but I think I have already tried everything I can think of.

Kernel crashes are usually caused by bad SD cards.

The SD card is fine. Two separate new SD cards produced the same kernel crash. The problem was fixed by going back to v0.20.7.

I did some additional testing on the card that had v0.20.8 on it. It had dashboard version 2.16.3 on it. I thought maybe since the card with 2.15.5 and the card with 2.17.0 worked with v0.20.7 that maybe the issue was dashboard 2.16.3. So I upgraded the dashboard to 2.17.0. But that did not fix the problem.

I then used npm to downgrade the v0.20.8 SD card to v0.20.7 and rebooted. As soon as I did that, everything started working as it should. So the problem is definitely with v0.20.8. I will stick to v0.20.7 since I know it works. So now I have 3 SD cards with v0.20.7 on them and all 3 works as designed.

Just noticed that this is on a Pi Zero W. Have you tried on a full-sized Pi, I'm just wondering if the Zero with Buster is the issue?

No, I haven't tried a full sized Pi as I don't have one. I specifically bought the Zero W because of the small size and Wifi capability. The application only needs to monitor incoming messages from the ESP32 and update the status of the Dashboard.

Maybe the script requires too much RAM to run but I would think 512MB would be more than sufficient. Since npm works fine for installing Node-RED, I will just use it on the Pi Zero W's. I have a couple of friends who want to duplicate my system. I am writing instructions for them so I will just have them use npm since the script doesn't work.

Installed 1.0 on a Pi 0W 2 or so days ago. Fresh Buster install, using the pi script. Took about 15-20 minutes to install, but worked fine.

1 Like

afelix, did you install the Buster with recommended software, Buster desktop, or Buster lite version? I have been using the Buster with recommended software for my Zero W installs.