Error delivering message to node:undefined [undefined]

Hello,

I've been building a sub-node to control lights in my home.
The sub-node is working as it should now, but I'm getting the following error on the debug window every time I deploy it after a change:

12/30/2024, 8:42:46 AMmsg : string[54]
"Error delivering message to node:undefined [undefined]"
12/30/2024, 8:42:46 AMmsg : string[316]
string[316]

TypeError: sendEvent.destination.node.receive is not a function
    at deliverMessageToDestination (/opt/node_modules/@node-red/runtime/lib/flows/Flow.js:803:40)
    at Immediate._onImmediate (/opt/node_modules/@node-red/runtime/lib/flows/Flow.js:819:21)
    at process.processImmediate (node:internal/timers:476:21)

12/30/2024, 8:42:46 AMmsg : string[54]
"Error delivering message to node:undefined [undefined]"
12/30/2024, 8:42:47 AMmsg : string[316]
string[316]

TypeError: sendEvent.destination.node.receive is not a function
    at deliverMessageToDestination (/opt/node_modules/@node-red/runtime/lib/flows/Flow.js:803:40)
    at Immediate._onImmediate (/opt/node_modules/@node-red/runtime/lib/flows/Flow.js:819:21)
    at process.processImmediate (node:internal/timers:476:21)

12/30/2024, 8:42:47 AMmsg : string[54]
"Error delivering message to node:undefined [undefined]"
12/30/2024, 8:42:47 AMmsg : string[316]
string[316]

TypeError: sendEvent.destination.node.receive is not a function
    at deliverMessageToDestination (/opt/node_modules/@node-red/runtime/lib/flows/Flow.js:803:40)
    at Immediate._onImmediate (/opt/node_modules/@node-red/runtime/lib/flows/Flow.js:819:21)
    at process.processImmediate (node:internal/timers:476:21)

As you can see, the same error is shown three times. At first it was shown only once, but as I've been working on the sub-node, more errors are shown at the time of deployment.

At first, I ignored the messages as the sub-node was working as it should, but as I'm trying to optimize the sub-node and add more features, I am getting weird behavior in some of the nodes inside the sub-node, leading to unexpected results. For example, in this portion of the sub-node:

image

The sun-position node should give the information on when the sunset, sunrise, dawn, dusk, etc. should happen today, and then the Custom Evening End Time node adds a custom evening end time to the message. The weird thing is that the custom evening end time information is being sent by sun-position node when it haven't been added to the message by Custom Evening End Time node yet.

Not sure if this weird behavior is related to the error messages but I would like to solve the errors before continuing troubleshooting any other issue. So here I am asking for some guidance on how to tackle those error messages. Any advice with be greatly appreciated.

Usually increasing numbers of messages with each deploy indicates that on the close of a node (ie a deploy) that some event handler is not being unloaded/removed so a new one gets added on every deploy...

Thanks @dceejay for the reply. Where can I check and remove those event handlers?

See https://nodered.org/docs/creating-nodes/node-js#closing-the-node

@Seba-VT

Just to focus in on what we are saying here.
The node you are using sun-position

May not be cleaning up resources (where it should be)

you will need to raise this with the author.

Link: Issues · rdmtc/node-red-contrib-sun-position · GitHub