How Do I Find Lost Junctions

As the topic says. I found junctions being placed NOT under the cursor so would like to check that I have found them all.

A little more info please like NR version, a copy of the flow tab you see the issue, a screen shot of the problem. All that would be helpful.

Here is a flow to find all the junctions in /home/pi/.node-red/flows.json. (change the filename to suit your setup).
It lists the ID of each junction (I don't think that you can find a junction by it's id?) and the name of the editor tab it's on.
Junctions with no outgoing wires are listed via a seperate debug node, on the assumption that these are more likely to be unwanted.
It even comes with a free unconnected junction.
I think it works whether flowFilePretty in settings.js is true or false.

[{"id":"72e3ac42d134d33c","type":"tab","label":"Find Junctions","disabled":false,"info":"","env":[]},{"id":"cd87c7e79d58104f","type":"junction","z":"72e3ac42d134d33c","x":560,"y":80,"wires":[[]]},{"id":"bcd4bc8e5fa549df","type":"file in","z":"72e3ac42d134d33c","name":"","filename":"/home/pi/.node-red/flows.json","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":300,"y":100,"wires":[["5989a3158b6f6489"]]},{"id":"5989a3158b6f6489","type":"json","z":"72e3ac42d134d33c","name":"","property":"payload","action":"","pretty":false,"x":150,"y":160,"wires":[["d01ad68650990728"]]},{"id":"f492b248145e9d02","type":"inject","z":"72e3ac42d134d33c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":100,"wires":[["bcd4bc8e5fa549df"]]},{"id":"05ba2a95c3f30851","type":"debug","z":"72e3ac42d134d33c","name":"Junctions with outgoing wires","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":140,"wires":[]},{"id":"79c471bdce623a4f","type":"function","z":"72e3ac42d134d33c","name":"function 29","func":"let tablist = flow.get(\"tablist\")\nfor (let i in msg.payload) {\n    let newmsg = {}\n    if (msg.payload[i].type == \"junction\") {\n        newmsg.payload = {\"id\": msg.payload[i].id, \"Tab\": tablist[msg.payload[i].z]}\n        if (msg.payload[i].wires[0].length == 0) {\n            node.send([null, newmsg])\n        }\n        else {\n            node.send([newmsg, null])\n        }\n    }\n}\nreturn (tablist)\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":160,"wires":[["05ba2a95c3f30851"],["c782a65a2cdc9371"]]},{"id":"c782a65a2cdc9371","type":"debug","z":"72e3ac42d134d33c","name":"Junctions with no outgoing wires","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":180,"wires":[]},{"id":"d01ad68650990728","type":"function","z":"72e3ac42d134d33c","name":"Find tab names","func":"let tablist = {}\nfor (let i in msg.payload) {\n    let newmsg = {}\n    if (msg.payload[i].type == \"tab\") {\n        tablist[msg.payload[i].id] = msg.payload[i].label\n    }\n}\nflow.set(\"tablist\", tablist)\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":160,"wires":[["79c471bdce623a4f"]]}]
1 Like

Have you tried ctrl-f junction ? (In the node-red editor)

I have, but it doesn't find junctions. In contrast to ctrl-f group, which finds groups.

Hmmmm it's possible "junction" is not indexed. Should probably be raised as an issue.

Node-RED 301.0 beta2 is where the junctions were not being placed under the cursor (see Node-RED 3.1.0-beta.2 released) for details

However, I have also tried on v3.02 and I still haven't found a way of finding junctions. As jbudd says, ctrl-f junction does not work (type in junction - no matches found)

@jbudd Thank you for the flow, it does work. I now know I have a couple of random junctions somewhere, but no way of finding them :thinking:

We don't index junctions because you cannot edit any properties and give them names. So any search will just give you a long list of "junction" and no actual help narrowing down the one you are looking for.

It would be handy if I could get them to show up at all. From the flow above I have 2 junctions floating, I also have the ids & Tab

I finally found them under a group. (lots of moving stuff around required)

That's odd. Groups are drawn on a lower layer to all nodes, so should never obscure them.

Sorry, when I said 'under a group' I meant under a node in a group. I moved a whole bunch of nodes as part of a group and that was when it became visible.

Wasn't the node showing the overlapping nodes warning?

That would only happen if nrlint was installed, which it isnt by default.

Colin, no overlapping nodes warning.

Should I be installing nrlint, and if so what are the downsides for an old guy who likes things straight-forward?

Oh yes, I had forgotten that.

As an old guy who likes tidy code, I always run with nrlint enabled. With default settings it may light up like a yuletide festival when you first activate it, but you can choose either to disable certain checks (like "default name") or enjoy that same sense of self-satisfied smugness following a thorough spring cleaning if you go through and address them all. Then, going forward, you get nice warnings that are easy to address as you go.

1 Like

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