Setup node variables in function node on start

Hi folks,

My first question in 2022, and it is a noob level one. First time that I use the "On start" tabsheet in the function node...

All my code in the "On start" tabsheet is executed correctly, but when I add this:

node.workers = [];

And I use that node variable in my "On message" tabsheet:


Then I get "TypeError: Cannot read property 'push' of undefined" in my Debug sidebar.

I suppose it is something ridiculous, but can't see it. When I debug the code, the node variable is nicely available and I can use it here e.g. to show an initial node status.


Hmm, don't think it has anything to do with my startup tabsheet.

  1. For the first message that I inject, an element is added correctly to my array:


  2. When I inject another message my array is undefined again:


I am ready for the madhouse at the moment...

Use context not node to store values across different calls to the function

1 Like

Thanks Nick!
Not sure how I could have overlooked that ...

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