Dynamic, live debug & message tracing

Hi There,

I have heard that one minor bugbear about Node-RED is debugging. Typical scenario is the missing debug node and having to add it, then having to redeploy and then having to restart the flow. And then nothing happens because the problem seems to have "fixed" itself.

Arising out of a desire to have message tracing, I've put together a dynamic debugger - in was not my intention but it just happened.

What this does is allow dynamic toggling of debug messages (plus message tracing). By dynamic I mean no deploy or flow restart necessary. The animation shows how it works:

msgtracer6

Step one is that I turn on message tracing and see in live where messages are flowing. Second step I turn "Msg to Debug" and suddenly all messages that are currently flowing around Node-RED are sent to the debug panel. The debug panel works as expected, just as if the debug node had sent the message.

Notice that the deploy button does not change - there is no need to redeploy or restart the flow, nor to add debug nodes.

Also the difference here to the debug node (which can also be toggled) is that there is no debug node - this is a catch all, debug all feature. It will also debug debug nodes!

Why? Because quite a few people have issues with debugging Node-RED and getting insides into what Node-RED is actually doing - in live.

Either way, this is all available in the introspection package version 0.8.5.

This feature has no overhead (neither client nor server) if not utilised - the hooks and communication are removed when the message tracing is deactivated - the backend has no extra overhead by installing this node package and not activating the message tracing.

DISCLAIMER:

The Node-RED editor can be seriously impeded if there are many messages circulating in Node-RED, use with care else the editor might literally freeze up. This could definitely also happen to the backend since each message is sent over the wire to the client - PLEASE be careful.

If unsure, don't use.

3 Likes

With 0.9.4 I've made an important change: all nodes and message are no longer traced by default. Tracing only works on a selection of nodes.

Also msg tracing and sending messages to debug are two separate operations, neither by default working all nodes and flows.

Instead a selection of nodes must be made - upon which to act - or if you really want to trace and debug everything there is an extra "All nodes?" checkbox that can be used to confirm that desire.

I think this will prevent accidental damage and frustration.

I put up a short writeup on this feature and that reminded me of an important point:

If you are going to use this, then turn it off before exiting the editor else the server will continue to send messages to the client. If this does happen, then reopen the editor and toggle the feature on/off and that will clean up the server, i.e., remove event listening hooks.