# Error delivering message to node:undefined \[undefined\]

**URL:** https://discourse.nodered.org/t/error-delivering-message-to-node-undefined-undefined/94256
**Category:** General
**Created:** [30 December 2024 16:06 UTC](https://discourse.nodered.org/t/error-delivering-message-to-node-undefined-undefined/94256 "2024-12-30T16:06:32Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Seba-VT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/seba-vt/32/91929_2.png) [@Seba-VT](https://discourse.nodered.org/u/Seba-VT)
#### Post date: [30 December 2024 16:06 UTC](https://discourse.nodered.org/t/error-delivering-message-to-node-undefined-undefined/94256/1 "2024-12-30T16:06:32Z")

</div>

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:

```auto
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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/f/9f16634eefb2e7fdb3021aa1eceb76661bfeb8de.png)

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.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [30 December 2024 16:09 UTC](https://discourse.nodered.org/t/error-delivering-message-to-node-undefined-undefined/94256/2 "2024-12-30T16:09:39Z")

</div>

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...

---

<div class="post-metadata">

### Author: ![Seba-VT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/seba-vt/32/91929_2.png) [@Seba-VT](https://discourse.nodered.org/u/Seba-VT)
#### Post date: [30 December 2024 16:21 UTC](https://discourse.nodered.org/t/error-delivering-message-to-node-undefined-undefined/94256/3 "2024-12-30T16:21:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [30 December 2024 16:39 UTC](https://discourse.nodered.org/t/error-delivering-message-to-node-undefined-undefined/94256/4 "2024-12-30T16:39:22Z")

</div>

> [@Seba-VT](#):
>
> Where can I check and remove those event handlers?

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

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [30 December 2024 17:53 UTC](https://discourse.nodered.org/t/error-delivering-message-to-node-undefined-undefined/94256/5 "2024-12-30T17:53:48Z")

</div>

@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](https://github.com/rdmtc/node-red-contrib-sun-position/issues)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [30 March 2025 17:54 UTC](https://discourse.nodered.org/t/error-delivering-message-to-node-undefined-undefined/94256/6 "2025-03-30T17:54:14Z")

</div>

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