Nodes with internal variables and "context"

In the editor screen you can see any context data for nodes using the context mode - top right of window - either by clicking on the icon or selecting it from the menu.

Screenshot from 2020-03-17 08-02-57

This works for function nodes, but it doesn't work for pre-built nodes which have their internal values.

Can/could it be possible to see them via this?

I am asking because I have been debugging stuff and need to know what some pre-built nodes have inside them, but can't get to or see.

Just a question.

Most of the nodes don't use context to store their internal state. They would need rewriting to use context in order to make their values visible in the context sidebar. In may cases, it wouldn't be suitable to do that.

You can see the internals of the running Node-RED system by using Node.js's --inspect debugging option.

Thanks @knolleary and @TotallyInformation.


As an example, I am using the node-red-contrib-counter node.

It gets stuck somewhere and I want to see the count value in the node.

I'm not sure how to apply what you say so I can (just hypothetically speaking) hover the mouse over the node and see the count value.

With function nodes I set the right side of the screen - as mentioned - and I can see the context stuff.

But as Nic' has said: They aren't using context to store their internal values.

That node is a recent example.

Does that help with helping me find a way to see their values?

Well, it isn't going to be quite that simple. You need to run Node-RED under --inspect and then pause it as soon as it starts. Then you can step through things.

If you want to inspect a particular node, you can manually add a breakpoint in the node.

It takes some practice and some knowledge - another thing to learn :wink:



Ok. So with that knowledge I shall have to do some thinking.

So, going on what you said, I have to start NR from the CLI/Terminal and run it as:
node-red --inspect yeah?

I guess I could also go to the other end and just stick debug nodes on the output of said nodes and log their output.

Looking at/in the debug node there is the system console option. But info doesn't really elaborate on that.
If I have 3 nodes doing that I'm guessing I need 3 system consoles open?

I'll maybe play with that now for a while and get a feel of how it works.
But if you could help confirm my thoughts; it would be appreciated.

I just tried that and have an inject node connected to a debug node and ticked the system console option ticked.

I press the inject and....... I see the output at the right of the screen, but system console.....

Where is it?

I have this in my package.json file's scripts section.

node --inspect node_modules/node-red/red.js --userDir ./data

(Just remember that I have Node-RED installed locally not globally which is why that looks a little different. You will need to know where the global installed version of Node-RED exists, you can find that by running which node-red in a Linux terminal.)

That won't tell you what is happening internally though will it? If that is what you really want.

No, debug output can either go to the debug panel, the Node-RED log or the node's status line, that's it. If you choose console output, everything goes to the Node-RED log.

To view the log depends on how your are running Node-RED. If you run manually from a terminal (console), then you see the output in the same place. If you ran a default install (on a Pi for example), you have to use the journalctl command to show the output of the log.


Yeah, I found something similar to what you said (sudo journalctl -f -u nodered -o cat).

But that is all nice, but not congruent with what is said in the debug node:
ie: system console.

To me it is a misnomer of sorts.

Since (by default) it is a ....... I don't even know what/where/which is the actual file name used. Guessing nodered........ The debug node text should be more correct (for people like me) in indicating where this file is.

As said: There is nothing written in the information part of the node.
Maybe just including that would help.

On a Pi it goes to /var/log/syslog and if you run node-red in a terminal (ie system console) using the node-red command or node-red-start then it also appears there. That is where the term 'system console' comes from, you will find the term used commonly in the Linux environment.

Perhaps. Why not head over to the #docs channel in slack and make a suggestion? You may well be asked to contribute the change to the docs.

Of course, there is a basic expectation that people have some understanding of the system they are hosting Node-RED on. After all, NR is a server component. The Raspberry Pi sometimes gives us, I think, unrealistic expectations in that it makes it so easy to get started with running a massively powerful computer server right their on our desktop. It is easy to forget the underlying complexity.

Anyway, you've triggered me now. I'm going to write #4 in an occasional series of Node-RED FAQ blog posts. "How to access the Node-RED logs". :slight_smile:

You will find it here once I've posted it:

1 Like

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