# Node-Red problem with messages in node.send(msg)

**URL:** <https://discourse.nodered.org/t/node-red-problem-with-messages-in-node-send-msg/13607>\
**Category:** General\
**Created:** [23 July 2019 12:27 UTC](https://discourse.nodered.org/t/node-red-problem-with-messages-in-node-send-msg/13607 "2019-07-23T12:27:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stamer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stamer/32/3464_2.png) [@stamer](https://discourse.nodered.org/u/stamer)\
**Post date:** [23 July 2019 12:27 UTC](https://discourse.nodered.org/t/node-red-problem-with-messages-in-node-send-msg/13607/1 "2019-07-23T12:27:28Z")

</div>

Hey,

I have problems with the call: node.send(msg).

When I call node.send(msg) within node.on('input', function(msg){}), it works, but this call within function Test(n) {} does not work always (sometimes, if the flow already exists!, but never after the whole flow was imported).  
I read docs regarding node.send(msg), e.g. How node.send() works, but I cannot fix this.  
Is this call synchronous (How node.send() works)?  
Should I call node.send(msg) within an asynchronous context?

Please help to get the right direction.

Many thanks.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [23 July 2019 13:52 UTC](https://discourse.nodered.org/t/node-red-problem-with-messages-in-node-send-msg/13607/2 "2019-07-23T13:52:35Z")

</div>

If you call node.send in your Node's constructor then you are calling it when the runtime is still starting up the flows. There is no guarantee that whatever your node is wired to exists yet.

Assuming you want your node to send a message each time your flows start (or are restarted due to a deploy etc) then you should wrap it in a setTimeout call with a short delay so the runtime can finish starting the flows before your node starts sending.

---

<div class="post-metadata">

**Author:** ![stamer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stamer/32/3464_2.png) [@stamer](https://discourse.nodered.org/u/stamer)\
**Post date:** [24 July 2019 08:44 UTC](https://discourse.nodered.org/t/node-red-problem-with-messages-in-node-send-msg/13607/3 "2019-07-24T08:44:54Z")

</div>

Hey Nick,  
thank you for the quick response. 🙂
