Also, could you post your function and a screenshot of the debug please?  What hardware/OS are you running on and what version of node red and nodejs?  The node red version is at the bottom of the menu dropdown and the nodejs version by  node -v  in a terminal