# Debugging ... little tweaks that perhaps can be useful

**URL:** https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542
**Category:** Feature Requests
**Created:** [24 December 2019 08:36 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542 "2019-12-24T08:36:19Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [24 December 2019 08:36 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/1 "2019-12-24T08:36:19Z")

</div>

Hi,  
like to suggest a few tweaks that could help with debugging

1. switch(es) to mute warn and error messages: I'm using some nodes which are very chatty, especially when working offline they are spamming the debug window with timeout and error messages disturbing any useful debugging. I can control my own debug nodes but not these. “Current flow only” doesn’t help here(?). The messages can/should still be send to the console.
2. Same problem as 1.) when filter "current flow” is active limit node.warn and node.error messages from nodes and subflows actually in this flow.
3. Pause debugging messages: when debugging it could happen that the messages I’m interested in disappear (because the buffer is filled) as long as I investigate the problem. Currently I make a screenshot but this is very limited. A simple pause/play button could help a lot.
4. While editing a subflow debug messages of the flow(s) the subflow is uses should appear here too when filter "current flow" is active
5. change node.warn and node.error functions to accept multiple arguments like `node.warn("Foo speaking:",msgObject, anotherVariable);` to make it possible to bring more information into one debug message. This could be displayed like an array with all arguments. Currently I use multiple node.warn messages.

I’m interested in how others solve this problems. Especially debugging JavaScript inside function nodes. I read that someone is building a temporary custom node for debugging- nice idea but a lot of effort in my opinion. I would love to have a way to use a "real" debugger instead of node.warn functions. My dream would be that it is possible to add a `debugger` statement into the function to trigger a debugger if connected similar to browsers.

Thank you for your attention  
Chris

---

<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: [24 December 2019 10:29 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/2 "2019-12-24T10:29:31Z")

</div>

Hi  
re 1) any one (or two) in particular - maybe we can get it fixed.  
2) yes - while not a bug is probably not what is desired - so a PR to address this would be welcome I think. (And likewise for "selected nodes" mode would also help fix 1)  
3) generally just by scrolling the window up it stops the window scrolling off for me ? Or are you getting so many that the buffer gets overfull and old ones disappear ?  
4) Does seem to make sense while editing - but if multiple instances of it are in use then it doesn't know which instance is it actually being debugged. They are not subroutines - they are a master instance and copies - so the master isn't actually running anything. (I think there is a special case where there is only one in use (eg just for code collapse/tidy) but we haven't explored that yet).  
5) need to be careful with anything that changes API/signature as once done it can't be undone without breaking people - so this would need careful consideration.

Nick was looking at a debug capability with breakpoints etc - but I think that was waiting for "pluggable message routing" that would allow people to plug in how messages pass from node to node (which itself was waiting for the async message passing we shipped in 0.20/1.0) - but would then allow things like inspectors and testers and debuggers to sit between every node.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [24 December 2019 10:31 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/3 "2019-12-24T10:31:54Z")

</div>

my tips:

- The debug node can be configured, most people seem to overlook this feature, but you can set it up to display something other than `msg.payload`, even better, you can even apply jsonata filters to it to only display what you are looking for (not sure if this filters out timeouts/warns)
- Once a flow is working: remove the debug node or "silent" it.
- Use selected nodes as filter.
- I can see advantages to filter within the debug node to get rid of warn/timeouts, then again it is a 'debug' node.

If debugging is required you can always attach a debug node.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [24 December 2019 11:10 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/4 "2019-12-24T11:10:22Z")

</div>

> [@Christian-Me](#):
>
> change node.warn and node.error functions to accept multiple arguments like `node.warn("Foo speaking:",msgObject, anotherVariable);`

node.warn("Foo speaking+msgObject+" "+anotherVariable)

---

<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: [24 December 2019 11:26 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/5 "2019-12-24T11:26:50Z")

</div>

Or, using the new(ish) string interpolation syntax

```auto
node.warn(`Foo speaking: ${msgObject} ${anotherVariable}`)

```

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [24 December 2019 11:28 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/6 "2019-12-24T11:28:50Z")

</div>

Hi, thank you for your quick an elaborate answer. A lot to think about.  
Just quickly:  
3.) yes, the scrolling stop as intended but the nodes are sometimes filling the buffer up, especially when node.warn had to be placed inside a loop (this is one reason why I came up with 5 to reduce the amount of messages)

And I forgot 6) I know about filter selected nodes but could it be perhaps handy if I can select a debug note in the flow and the debug window filter only the messages from this debug note. The other way around works fine but often I see me clicking through many messages to find the right one. Since a while I name all my debug nodes to avoid this.

Chris

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [24 December 2019 11:30 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/7 "2019-12-24T11:30:40Z")

</div>

Thank you for this hint, will try out ASAP because + is not working for objects (and Arrays)

---

<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: [24 December 2019 11:36 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/8 "2019-12-24T11:36:19Z")

</div>

> [@Christian-Me](#):
>
> - is not working for objects (and Arrays)

`node.warn()` needs a string or something that can be converted automatically to a string. That is the problem trying to output objects and arrays, not the `+`

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [24 December 2019 11:49 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/9 "2019-12-24T11:49:15Z")

</div>

Sorry ... not working (here)

```auto
node.warn('Foo speaking: ${config}');

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/17ea14d9d9c71344396ce6b21fd14b16ad70e78f.png)

And this as expected:

```auto
node.warn('Foo speaking: '+config);

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e18520a1406c9a5e75727b425a9c31b03a6b332e.png)

and what I normaly do, nice object view but two messages:

```auto
node.warn('Foo speaking:');
node.warn(config);

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/6c87388262cf65531802c961d72e49218775e45d.png)

this works but that's not the way to do it, right?

```auto
console.log('Foo speaking:',config);

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9e9ae0df197af578370ca09a5ff03774138b9cd9.png)

---

<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: [24 December 2019 11:56 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/10 "2019-12-24T11:56:18Z")

</div>

> [@Christian-Me](#):
>
> node.warn('Foo speaking: '+config);

Maybe try `node.warn('Foo speaking: '+JSON.stringify(config));`

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [24 December 2019 12:17 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/11 "2019-12-24T12:17:57Z")

</div>

> [@dceejay](#):
>
> node.warn('Foo speaking: '+JSON.stringify(config));

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d09a9e6bfed1ee5dad9437d17fb17283c969f5c7.png)

working but not so nice (and difficult to read bigger objects: all in one long line and it is going far to the right that perhaps it is already is in another time zone or climate (Kevlin Henney)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/898c992eec54dea3999b98dcbcb9415aff6e22bd.png)

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [24 December 2019 12:22 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/12 "2019-12-24T12:22:44Z")

</div>

> [@Christian-Me](#):
>
> Sorry ... not working (here)
> 
> ```auto
> node.warn('Foo speaking: ${config}');
> 
> ```

The reason that one doesn't work is because you use the wrong type of quotes. The type of string you use is the template/formatting string introduced to ES6, and in order to use variable inside it through the `${var_name}` syntax you have to use backticks rather than regular quotes:

```auto
node.warn(`Foo speaking: ${config}`);

```

It's a tiny difference, but that should work.  
Or to put it all together:

```auto
node.warn(`Foo speaking: ${JSON.stringify(config)}`)
```

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [24 December 2019 12:33 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/13 "2019-12-24T12:33:33Z")

</div>

sorry not here:  
copy/paste both versions and seams no difference to the joining the strings with the `+` operator

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b60a13d4e7f643d48436071b6c5bf11a0beff074.png)

---

<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: [24 December 2019 12:33 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/14 "2019-12-24T12:33:33Z")

</div>

There are extra options on stringify that will make it prettyprint if you like - [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/JSON/stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)  
eg -

```auto
JSON.stringify(config, null, 2);

```

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [24 December 2019 12:41 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/15 "2019-12-24T12:41:45Z")

</div>

> [@dceejay](#):
>
> JSON.stringify(config, null, 2);

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f44fb7971c88e66537f73ced9caa9840f8abafb7.png)

Ok, all in one time zone but I think I prefer the double node.warn if necessary. Most of the time I can identify the source by the data and prefer the collapsible lists for bigger objects (the example is only a small one)

Thank you all for the great input and "Marry Christmas".  
In Germany we are celebrating on Christmas eve so a lot of preparation is waiting....

---

<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: [24 December 2019 12:45 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/16 "2019-12-24T12:45:49Z")

</div>

ah yes - we replace formatting with codes ... ah well. (will look nicer in the console 😉

---

<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: [24 December 2019 15:06 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/17 "2019-12-24T15:06:54Z")

</div>

Back to your original request - which nodes are causing grief for 1) ?  
I have tried several simple use cases and the filter by tab does exclude node.warn and node.error from other tabs... so ...

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [25 December 2019 13:24 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/18 "2019-12-25T13:24:09Z")

</div>

Hello form Berlin,

sorry to come back to you late. Especially this one which connects homematic devices to Node-RED is very chatty.

> **[node-red-contrib-ccu](https://flows.nodered.org/node/node-red-contrib-ccu)**
>
> Node-RED Nodes for the Homematic CCU

It is the configuration node (named ccu2) sending this warnings / messages. Normally I disable the config node when I work offline but they also appear (not so often) when working online as the homemeatic hub (called ccu2) is not the best piece of hardware/software I know.  
As config nodes are not placed inside a flow the messages bypass the filter (current flow) and appear everywhere. This is why I thought a mute switch would be the easiest solution. But perhaps you can filter them out. If no node placed on the current flow using a config node sending node.warn or node.error messages don`t display them.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/44a430a4471891a62df0ec02842bd01a2d074a59.png)

Christmas greetings, Chris

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [28 December 2019 14:16 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/19 "2019-12-28T14:16:59Z")

</div>

Another thing I recognize related to point 3: Even if the filter is set to current flow, and the current flow is not filling the buffer other debug messages (not visible because filtered out) can cause the visible messages disappear.  
The logic is clear and appreciated when switching through flows you always see the recent messages but sometimes I would like to push a ⏸ pause button. Scrolling back a little does the job but in my case don’t last long until the buffer fills up - so read fast and think faster 😉 maybe a solution too (or perhaps separate buffers or pointers/counters?)

A “clear all breakpoints” here mute all debug notes could be handy too. My flows looks often like an open heart surgery and are sometimes bigger than the screen ...  
A pause button for the runtime could be nice to but that’s another story.

I’m worried that I’m asking for too much - Only some suggestions for future updates.

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [14 January 2020 19:12 UTC](https://discourse.nodered.org/t/debugging-little-tweaks-that-perhaps-can-be-useful/19542/20 "2020-01-14T19:12:41Z")

</div>

It took a while and we were so close:

```auto
node.warn([“Foo speaking”,config]);

```

All in one container nicely arranged!  
(No screenshot because I’m writing it on the train)
