# Subroutine Missing return node information

**URL:** https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289
**Category:** General
**Created:** [4 January 2024 15:12 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289 "2024-01-04T15:12:48Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:12 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/1 "2024-01-04T15:12:48Z")

</div>

I have this subroutine which I am calling with a` link call` node:

 ![Screenshot 2024-01-04 alle 16.10.24](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/a/ea4343d9478ec7638cc545e8a00a07d563e41f43.png)

I am always getting "`Missing return node information`", due to the split function, which contains:

```auto
msg.payload.split("##").forEach(e => { 
    if (!e) {return;}
    node.send({ payload: e + "##"}) 
    
});

```

Any way to let it work?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 January 2024 15:17 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/2 "2024-01-04T15:17:10Z")

</div>

> [@fmarzocca](#):
>
> Any way to let it work?

Dont throw away the original message. It contains the routing info for the subroutine to return to.

But - you might have a different issue here - splitting will generate multiple responses. A link return should only be triggered once per call.

My suggestion is to do the splitting OUTSIDE of the subroutine.

Or, only return a single msg (the original msg object, complete with its original .\_link property) after everything is done.

maybe you should explain in words what overall goal is?

EDIT

Do you _really_ need to send individual messages?

It would likely be better to process the split lines into an array in payload then use the `split` node AFTER the link-call

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:20 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/3 "2024-01-04T15:20:48Z")

</div>

I'm afraid I can't do it outside as I need this in 240 different nodes in my project. The input in the function is a long string of messages separated by "##", which I should need to split. (i.e: `*#*1##*#*1##*#18*74#0*113*0##*#*1##)`

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:23 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/4 "2024-01-04T15:23:22Z")

</div>

What I need to do is to discard all parts like this:` *#*1##` and keep the valid message.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 January 2024 15:25 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/5 "2024-01-04T15:25:02Z")

</div>

This doesnt make a whole lot of sense to me.

are you expecting 1 or multiple messages to be sent back from the subroutine?

can you share:

- 1 or 2 sample data (that the exec would send)
- this subroutine so I can see what it is doing
- what the message(s) should liike like AFTER the processing of this subroutine

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:28 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/6 "2024-01-04T15:28:21Z")

</div>

That's not easy, as this is a OWN bus (Legrand) and you can't replicate on your own.  
But take that message: `*#*1##*#*1##*#18*74#0*113*0##*#*1##`  
I don't need to extract ALL of the messages, but just `*#18*74#0*113*0##`, discarding the rest. But this central message can vary, depending on the input in the subroutine.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 January 2024 15:31 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/7 "2024-01-04T15:31:59Z")

</div>

> [@fmarzocca](#):
>
> That's not easy, as this is a OWN bus (Legrand) and you can't replicate on your own

I dont need anything other than 1 or 2 example (input) data strings, a copy of this subroutine and your answers to "what the message(s) should liike like AFTER the processing of this subroutine?" and "are you expecting 1 or multiple messages to be sent back from the subroutine?"

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:32 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/8 "2024-01-04T15:32:21Z")

</div>

Currently I am doing this in a subflow (which is working) but I'd like to move it into a subroutine

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 January 2024 15:33 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/9 "2024-01-04T15:33:26Z")

</div>

And i can help you if you answer the questions and select + export the 8 nodes in this picture:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/09f804ec4702a114f81d6d96b2b14bda6c3b74bd.png)

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:35 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/10 "2024-01-04T15:35:58Z")

</div>

[flows.json](https://discourse.nodered.org/uploads/short-url/o0yRPpQ2WvDE4mB6s7cBdmK7OKg.json) (4.3 KB)  
Attached

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:41 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/11 "2024-01-04T15:41:33Z")

</div>

This is another message out of the exec: `*#*1##*#*1##*#18*5158*113*490##*#*1##`

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 January 2024 15:41 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/12 "2024-01-04T15:41:33Z")

</div>

for future reference, please just paste the JSON into a code block.

ok you still haven't answered the questions. Let me phrase this a different way.

Suppose the subroutine was triggered and the response from the EXEC was `*#*1##*#*1##*#18*74#0*113*0##*#*1##`:

- how many messages would you expect to be outputted from your function nodes?
- what would they contain?

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:43 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/13 "2024-01-04T15:43:03Z")

</div>

Yes, I answered [here](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/6)  
Anyway, I just need `*#18*74#0*113*0##` discarding the rest. One message.

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:45 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/14 "2024-01-04T15:45:52Z")

</div>

One more thing: pls discard the function in "COnverte e filtra output". It is not needed

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 January 2024 15:49 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/15 "2024-01-04T15:49:33Z")

</div>

> [@fmarzocca](#):
>
> Anyway, I just need `*#18*74#0*113*0##` discarding the rest. One message.

I assume the values change so what defines the part of interest?

e.g. will it always be `*#*1##*#*1##[xxxxxxxxxxx]*#*1##` where `xxxxxxxxxxx` is the interesting part?

is there a document that states the structure of this data?

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 15:52 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/16 "2024-01-04T15:52:09Z")

</div>

> [@Steve-Mcl](#):
>
> e.g. will it always be `*#*1##*#*1##[xxxxxxxxxxx]*#*1##` where `xxxxxxxxxxx` is the interesting part?

YES, as I said the content can change, but the part of interest is always that one, discarding all `*#*1##`. parts

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [4 January 2024 16:06 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/17 "2024-01-04T16:06:59Z")

</div>

Your OG split should work fine , as Steve said, send the OG msg , do not construct a new message.  
This should work also

```auto
msg.payload = msg.payload.split("*#*1##").find((str) => str);
return msg;

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 January 2024 16:07 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/18 "2024-01-04T16:07:39Z")

</div>

does this look right?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35250bf7724440ce0a3bb94c76d76dd41bba3621.png)

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [4 January 2024 16:09 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/19 "2024-01-04T16:09:24Z")

</div>

> [@Steve-Mcl](#):
>
> does this look right?

it looks very much right!

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 January 2024 16:11 UTC](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289/20 "2024-01-04T16:11:39Z")

</div>

Try this then.

you will need to remove the "fake data" node and check that the output of the EXEC maintains the `msg.linksource` property for it to work in production.

```auto
[{"id":"f4fddf75fcab76bd","type":"inject","z":"eaa6d97a6ede80ab","name":"*#*1##*#*1##*#18*5158*113*490##*#*1##","props":[{"p":"data","v":"*#*1##*#*1##*#18*5158*113*490##*#*1##","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":1060,"y":2780,"wires":[["651dee8c58c1df85"]]},{"id":"dd4dba7aa1c70279","type":"inject","z":"eaa6d97a6ede80ab","name":"*#*1##*#*1##*#18*74#0*113*0##*#*1##","props":[{"p":"data","v":"*#*1##*#*1##*#18*74#0*113*0##*#*1##","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":1070,"y":2820,"wires":[["651dee8c58c1df85"]]},{"id":"38eb990e6db1dcc8","type":"inject","z":"eaa6d97a6ede80ab","name":"*bad-data*#18*5158*113*490*bad-data*","props":[{"p":"data","v":"*bad-data*#18*5158*113*490*bad-data*","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":1070,"y":2860,"wires":[["651dee8c58c1df85"]]},{"id":"651dee8c58c1df85","type":"link call","z":"eaa6d97a6ede80ab","name":"","links":["8b9393b8466fa7c0"],"linkType":"static","timeout":"30","x":1410,"y":2820,"wires":[["12de24bc0b74b5c3"]]},{"id":"12de24bc0b74b5c3","type":"debug","z":"eaa6d97a6ede80ab","name":"debug 128","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1470,"y":2880,"wires":[]},{"id":"01ad3b3ec8cc86aa","type":"group","z":"eaa6d97a6ede80ab","name":"ComandoGenericoOWN","style":{"label":true},"nodes":["c949ccec8874aa3f","ff31eb43d0d56564","8b9393b8466fa7c0","e43ce6325fd32295","9bc58c33413af99e","c34f56c232187db3","eb5f4a08de054e18","29886815c09103ca"],"x":904,"y":2929,"w":662,"h":212},{"id":"c949ccec8874aa3f","type":"exec","z":"eaa6d97a6ede80ab","d":true,"g":"01ad3b3ec8cc86aa","command":"/home/boss/.node-red/assets/send_SCS2.py","addpay":"payload","append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"send_SCS2.py","x":1100,"y":3040,"wires":[["ff31eb43d0d56564"],[],[]]},{"id":"ff31eb43d0d56564","type":"function","z":"eaa6d97a6ede80ab","g":"01ad3b3ec8cc86aa","name":"grab data part (or throw)","func":"\n// for downstream debugging when errors occur\nmsg._originalData = msg.payload\n\n// v1 is it is ALWAYS xxxx then simply split on that!\nconst star_hash_check = msg.payload.indexOf('*#*1##') > -1\nif (star_hash_check) {\n const result = msg.payload.split('*#*1##').filter(e => !!e)\n if (result.length) {\n msg.payload = result[0]\n return msg\n }\n}\n// if we reach here, then data not found, throw error\nmsg.payload = null\nnode.error(\"not found\", msg);\n\n\n// ---- alt ---- //\n// v2 - using regex with a capturing group\n// const result = /(?:\\*\\#\\*\\d+\\#\\#)+(.*)(?:\\*\\#\\*\\d+\\#\\#)+/.exec(msg.payload)\n// if (result.length > 1) {\n// msg.payload = result[1]\n// return msg\n// }\n\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1410,"y":3020,"wires":[["9bc58c33413af99e"]]},{"id":"8b9393b8466fa7c0","type":"link in","z":"eaa6d97a6ede80ab","g":"01ad3b3ec8cc86aa","name":"ComandoGenericoOWN","links":[],"x":945,"y":2970,"wires":[["c34f56c232187db3"]]},{"id":"e43ce6325fd32295","type":"function","z":"eaa6d97a6ede80ab","g":"01ad3b3ec8cc86aa","name":"","func":"// Se arriva un msg.options, \n// ha la priorità sull'impostazione di msg.payload\n\n\nif (msg.options) {\n msg.payload = msg.options;\n}\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1200,"y":2970,"wires":[["c949ccec8874aa3f","29886815c09103ca"]]},{"id":"9bc58c33413af99e","type":"link out","z":"eaa6d97a6ede80ab","g":"01ad3b3ec8cc86aa","name":"link out 4","mode":"return","links":[],"x":1525,"y":3080,"wires":[]},{"id":"c34f56c232187db3","type":"delay","z":"eaa6d97a6ede80ab","g":"01ad3b3ec8cc86aa","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1050,"y":2970,"wires":[["e43ce6325fd32295"]]},{"id":"eb5f4a08de054e18","type":"catch","z":"eaa6d97a6ede80ab","g":"01ad3b3ec8cc86aa","name":"","scope":"group","uncaught":false,"x":1360,"y":3080,"wires":[["9bc58c33413af99e"]]},{"id":"29886815c09103ca","type":"change","z":"eaa6d97a6ede80ab","g":"01ad3b3ec8cc86aa","name":"fake data","rules":[{"t":"move","p":"data","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":3100,"wires":[["ff31eb43d0d56564"]]}]

```

[Next page](https://discourse.nodered.org/t/subroutine-missing-return-node-information/84289.md?page=2)
