# How to track down Uncaught Exception

**URL:** <https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229>\
**Category:** General\
**Created:** [7 May 2020 10:33 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229 "2020-05-07T10:33:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [7 May 2020 10:33 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229/1 "2020-05-07T10:33:39Z")

</div>

note\* this issue is intermittent, over the last days its happens perhaps 3 times out of maybe 100 deploys.

I noticed instead of Deploying when I press the Deploy button on the editor, Node-Red restarts, first I thought perhaps I pressed Restart Flows on the Deploy menu because I was not taking enough notice what I was doing, but today I figured I had a problem and checked the logs see below.

here is the log ... how can I narrow down the issue I have huge multiple flows.

May 7 10:52:39 raspberrypi Node-RED[32577]: 7 May 10:52:39 - [red] Uncaught Exception:  
May 7 10:52:39 raspberrypi Node-RED[32577]: 7 May 10:52:39 - TypeError: Cannot set property 'socketid' of undefined  
May 7 10:52:39 raspberrypi Node-RED[32577]: at Object.beforeSend (/home/pi/.node-red/node\_modules/node-red-dashboard/nodes/ui\_template.js:79:33)  
May 7 10:52:39 raspberrypi Node-RED[32577]: at EventEmitter.handler (/home/pi/.node-red/node\_modules/node-red-dashboard/ui.js:285:26)  
May 7 10:52:39 raspberrypi Node-RED[32577]: at emitOne (events.js:121:20)  
May 7 10:52:39 raspberrypi Node-RED[32577]: at EventEmitter.emit (events.js:211:7)  
May 7 10:52:39 raspberrypi Node-RED[32577]: at emitOne (events.js:116:13)  
May 7 10:52:39 raspberrypi Node-RED[32577]: at Socket.emit (events.js:211:7)  
May 7 10:52:39 raspberrypi Node-RED[32577]: at /home/pi/.node-red/node\_modules/socket.io/lib/socket.js:528:12  
May 7 10:52:39 raspberrypi Node-RED[32577]: at \_combinedTickCallback (internal/process/next\_tick.js:131:7)  
May 7 10:52:39 raspberrypi Node-RED[32577]: at process.\_tickDomainCallback (internal/process/next\_tick.js:218:9)  
May 7 10:52:39 raspberrypi systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 May 2020 11:07 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229/2 "2020-05-07T11:07:56Z")

</div>

What versions of node-red, node-red-dashboard and nodejs are you running? The easiest way to answer may be to run, in a terminal  
`node-red-stop`  
`node-red-start`  
and post the output here.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 May 2020 11:13 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229/3 "2020-05-07T11:13:55Z")

</div>

Hi @Dave,

the stack trace includes `node-red-dashboard/nodes/ui_template.js` - so that points at one of your `ui_template` nodes.

However, this sort of error should not be left uncaught like this and an issue should be raised against `node-red-dashboard` so appropriate error handling can be added.

> [@Dave](#):
>
> May 7 10:52:39 raspberrypi Node-RED[32577]: 7 May 10:52:39 - [red] Uncaught Exception:  
> May 7 10:52:39 raspberrypi Node-RED[32577]: 7 May 10:52:39 - TypeError: Cannot set property 'socketid' of undefined  
> May 7 10:52:39 raspberrypi Node-RED[32577]: at Object.beforeSend (/home/pi/.node-red/node\_modules/ **node-red-dashboard/nodes/ui\_template.js** :79:33)

Before you do that, as Colin says, please confirm what version of Node-RED Dashboard you are using - just in case you are on an older version and this is already resolved in a more recent version.

/cc @dceejay for FYI

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [7 May 2020 11:17 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229/4 "2020-05-07T11:17:12Z")

</div>

node-red 1.0.1  
node-red-dashboard 2.19.4  
nodejs v8.11.3

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 May 2020 11:22 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229/5 "2020-05-07T11:22:38Z")

</div>

There was a previous report of the problem, suggesting that it is to do with the same template multiple times, but @max did not respond to a request for further information.

> [@Problem with multible Templates in group](https://discourse.nodered.org/t/problem-with-multible-templates-in-group/13346):
>
> Hi, i have the following error. i use a Template for a Button. (so i can use other Icons etc.) The template looks like: \<button class="single" ng-click="send(msg)" type="button"\>\<span class="{{msg.icon}} {{msg.state}}"\>\</span\>\</button\> i inject msg.payload etc via an function node. the Problem is: when i use this template multible times in one Group node red restarts. in the log file is see the following errors: 16 Jul 12:31:01 - [red] Uncaught Exception: 16 Jul 12:31:01 - TypeError: C…

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [7 May 2020 12:42 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229/6 "2020-05-07T12:42:28Z")

</div>

Hi Colin I don't think @max problem is the same one that I have, sure I am using many ui-template nodes (192) some are buttons but these have been working for a long time without issue, the only time I am hitting this intermittent problem is when I am modifying some thing and I press the Deploy button, the last time I had this problem (yesterday) I was not modifying the same flow as I was today, however both times I was working on different ui\_template nodes.

For sure this issue is not happening at any other time, I have multiple checks that alert me via prowl if something goes off-line but one sure fire way of telling is that I have two usb nas hard drives that are controlled via buttons on this pi if node-red restarts the usb's drop out and require a reboot to get them working again.

I can see this issue is going to be a pig to narrow down I think the best thing I can do is to continue doing what I am doing and monitor carefully to see if I can find some common causality, without more data its going to be like trying to find a needle in a haystack.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 May 2020 12:51 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229/7 "2020-05-07T12:51:55Z")

</div>

If you could still raise an issue on [https://github.com/node-red/node-red-dashboard/issues](https://github.com/node-red/node-red-dashboard/issues) that would be helpful.

It may be a pain to track down, but nothing a user does should cause an uncaught exception.

The stack trace points to this line:

```auto
                if (original) {
                    var om = original.msg;
                    om.socketid = original.socketid; // <------
                    return om;
                }

```

meaning, for some reason, `original.msg` is undefined at this point in time. I don't know enough of the inner workings of dashboard to say why that could be. But if we can get an issue raised that we can look at it properly.

Thanks.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [7 May 2020 13:03 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229/8 "2020-05-07T13:03:13Z")

</div>

Yes - if the template is "bad" and doesn't send a proper object (ie null) then yes - oops.  
Fixed in master on npm now. Now released as v2.22.0.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 May 2020 13:03 UTC](https://discourse.nodered.org/t/how-to-track-down-uncaught-exception/26229/9 "2020-05-21T13:03:19Z")

</div>

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