# Debug Node don't show output

**URL:** <https://discourse.nodered.org/t/debug-node-dont-show-output/63141>\
**Category:** General\
**Created:** [27 May 2022 09:56 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141 "2022-05-27T09:56:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [27 May 2022 09:56 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/1 "2022-05-27T09:56:54Z")

</div>

Hi, im trying to build a simple flow:

- An AWS Lambda Function that just return a value
- An input node that on trigger execute a Function Node that use AWS SDK in Js to simply invoke my function and save the message in msg.payload
- A Debug Node that should show the message, but slimply show "UNDEFINED"

As you can see in the Function node I save the message in the msg.payload but the Debug Node don't show it, but trying to console.log it I can read the result in the console without problem? Why I'm having this problem?

```auto
[
    {
        "id": "f6f2187d.f17ca8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "e72d8d71.b49a8",
        "type": "debug",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 730,
        "y": 200,
        "wires": []
    },
    {
        "id": "7690d6ae.421348",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "prova",
        "payloadType": "msg",
        "x": 320,
        "y": 200,
        "wires": [
            [
                "ffac1725.c59cd8"
            ]
        ]
    },
    {
        "id": "ffac1725.c59cd8",
        "type": "function",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "func": "var out;\nvar lambda = new AWS.Lambda({\n apiVersion: '2015-03-31',\n endpoint: 'http://172.18.0.4:4566',\n sslEnabled: false,\n region: 'us-east-2',\n accessKeyId: 'test',\n secretAccessKey: 'test'\n});\n\nvar params = {\n FunctionName: 'FindTarga', /* required */\n};\n\nlambda.invoke(params, function(err, data) {\n if (err) {\n console.log(err, err.stack); \n msg.payload=err;\n \n } // an error occurred\n else {\n out = data.Payload.toString(\"utf-8\");\n //console.log(out);\n msg.payload = out;\n console.log(msg.payload);\n }// successful response\n});\nreturn msg;",
        "outputs": 2,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [
            {
                "var": "AWS",
                "module": "aws-sdk"
            }
        ],
        "x": 540,
        "y": 200,
        "wires": [
            [
                "e72d8d71.b49a8"
            ],
            []
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [27 May 2022 11:56 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/2 "2022-05-27T11:56:08Z")

</div>

I rather suspect that some part of your function node is an async call. Therefore the function continues to the end before the async call has finished.

If so, you need to remove the `return msg` from the end of the function node and instead embed a `node.send(msg)` into the async function call.

---

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [28 May 2022 09:55 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/3 "2022-05-28T09:55:28Z")

</div>

Thanks it worked well, but now Im trying to send this payload to a Telegram Bot.  
Using an Input Node with Msg payload as string, a function for handle telegram message  
and telegram node works well, but trying to pass the payload of the previous function it doesn't send anything.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b92446dd4a2be4ffc32e0655c35d69dc3286c2ff.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 May 2022 22:42 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/4 "2022-05-28T22:42:10Z")

</div>

> [@BearGrillz](#):
>
> telegram node works well, but trying to pass the payload of the previous function it doesn't send anything.

Make sure you understand what you are sending to Telegram. It only permits quite limited output. Text-only by default. Limited formatting if you chose one of the formatted output types.

I generally use an MQTT topic as a root and have a single flow that checks and outputs to my bots. Makes it easy to ensure that the formatting and settings are correct.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/201e7bbb43c3a2a7ed5411c133ec445a387355fb.png)

---

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [29 May 2022 07:36 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/5 "2022-05-29T07:36:59Z")

</div>

How did you make ensure that the formatting and settings are correct?  
What Im sending is a utf-8, this should be good or not?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 May 2022 11:30 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/6 "2022-05-29T11:30:32Z")

</div>

> [@BearGrillz](#):
>
> How did you make ensure that the formatting and settings are correct?

The function node before the Telegram output node does that. The change nodes add the correct chat id.

They change what is possible from time-to-time so this code might be slightly out-of-date now but it may give you some hints:

````auto
let contentType = msg.contentType || 'message'
let mode = msg.mode || 'MarkdownV2' //'Markdown' // 'html'
let content = ''

// Make topic into a pseudo heading (Bold, Underline)
if (msg.topic) content += `__*${msg.topic.replace(/_/g, ' ')}*__\n`

// Allow complex payload, convert to Markdown
let sp
if (msg.payload) {
    sp = msg.payload
    
    // If payload is an array, assume an array of strings, otherwise try to turn into a string
    if (!Array.isArray(sp)) {
        // Try toString first
        try {
            sp = sp.toString()
        } catch (e) {}
        // Check if it is now `[object Object]`, if it is, try to JSON stringify it instead
        if ( sp === '[object Object]' ) {
            try {
                sp = JSON.stringify(msg.payload)
                // TODO: Maybe newline on comma and [ or { ? Maybe also make json props into bold or italic?
            } catch (e) {
                node.warn(`Cannot convert input payload to a string. ${e.message}`)
                return
            }
        }
        
        // If payload is a string, split on `<br>`
        if (typeof sp === 'string') sp = sp.split('<br>')
    }
    
    // If payload is an array, each element is a new line
    if (Array.isArray(sp)) content += sp.join('\n')
    else if (typeof sp === 'string') content += sp // belt and braces
}

// If content contains `.` - mode must be Markdown, not MarkdownV2!
if (mode === 'MarkdownV2') {
    if ( /[.{]/.test(content) ) mode = 'Markdown'
}

msg.payload = { 
    "chatId": msg.chatId,
    "content": content,
    "type": contentType,
    "options": { 
        "parse_mode": mode,
    },
}
return msg;

/**
 * Markdown V2 Styles - https://core.telegram.org/bots/api#markdownv2-style
 * 
 * *bold \*text*
 * _italic \*text_
 * __underline__
 * ~strikethrough~
 * *bold _italic bold ~italic bold strikethrough~ __underline italic bold___ bold*
 * [inline URL](http://www.example.com/)
 * [inline mention of a user](tg://user?id=123456789)
 * `inline fixed-width code`
 * ```
 * pre-formatted fixed-width code block
 * ```
 * ```python
 * pre-formatted fixed-width code block written in the Python programming language
 * ```
 * 
 */

````

---

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [30 May 2022 07:30 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/7 "2022-05-30T07:30:39Z")

</div>

But I don’t understand, the string is correctly formatted in UTF8 by my function before saving it into msg.payload so what I need to do? The msg.payload should be good

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [30 May 2022 20:16 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/8 "2022-05-30T20:16:29Z")

</div>

Sorry, without seeing an example of the output text, I can't say what the issue might be.

---

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [31 May 2022 13:36 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/9 "2022-05-31T13:36:54Z")

</div>

Executing the function node without set up the formatting part for Telegram, the Debug Node show the string as result:  
 ![Screenshot_2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/4/747764d13aad1e82263273c4bb0b9598df74d3ef.png)

Trying to build the object to send correctly the message adding this in my Function Node

```auto
    "chatId":167585253,
    "sentMessageId":46,
    "type":"message",
    "content":out 
};

```

the debug node show correctly the object created for sending message to telegram node:  
 ![Screenshot_1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/609bf97f36011ef98234ec8a319eeb0f980d8e13.png)

But telegram node doesn't send anything. If you need other proof im here, thanks for supporting me 😓 😓

P.S I'll put current flow in the next post

---

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [31 May 2022 13:37 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/10 "2022-05-31T13:37:25Z")

</div>

Here it the current flow

 ![Screenshot_3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/fee797981206a7fdb274e6d5280bf39349a5933e.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [31 May 2022 14:07 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/11 "2022-05-31T14:07:36Z")

</div>

Alessio, please open the function node and copy it's contents and paste it into a reply.

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [31 May 2022 14:18 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/12 "2022-05-31T14:18:05Z")

</div>

Here is the full Function. It simply call an AWS Lambda Serverless Function that return a string. I take the result from _data_, convert it into a UTF8 string and create the object for Telegram.

```auto
var out;
var lambda = new AWS.Lambda({
  apiVersion: '2015-03-31',
  endpoint: 'http://172.18.0.4:4566',
  sslEnabled: false,
  region: 'us-east-2',
  accessKeyId: 'test',
  secretAccessKey: 'test'
});

var params = {
  FunctionName: 'FindTarga', /* required */
};

lambda.invoke(params, function(err, data) {
  if (err) {
      console.log(err, err.stack); 
      msg.payload=err;
      
  } // an error occurred
  else {
      out = data.Payload.toString("utf-8");
      //console.log(out);
      //msg.payload = out;
      console.log(msg.payload);
      msg.payload = {
    "chatId":167585253,
    "sentMessageId":46,
    "type":"message",
    "content":out
    
};
      node.send(msg);
  }// successful response
});

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [31 May 2022 15:02 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/13 "2022-05-31T15:02:01Z")

</div>

What options do you have set in the debug node?  
if nothing is set in the debug side panel then I'm guessing that you `debug window` unchecked. and `node status (32 characters)` checked. you can have them both checked.

also name the `debug` node so you can make sure it is the one you are looking at in the debug log.

---

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [31 May 2022 15:07 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/14 "2022-05-31T15:07:04Z")

</div>

Debug Node is good, I have checked `debug window` and `node status`. I have only this debug node currently in this workflow. Why I can see correctly the debug, but not send the message to telegram?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [31 May 2022 15:15 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/15 "2022-05-31T15:15:26Z")

</div>

In the `Telegram Sender` node, have you tried checking the `Send errors to second output` box and attaching a debug node to it to see if anything shows. You could also add a `catch` node (targeting the `Telegram Sender` node) connected to a `debug` node too see what it will show.

---

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [31 May 2022 15:29 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/16 "2022-05-31T15:29:09Z")

</div>

Nope, no error at all. Tried in both ways you said, it show no errors  
I don't know what to do 😪

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [31 May 2022 15:41 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/17 "2022-05-31T15:41:47Z")

</div>

> [@BearGrillz](#):
>
> string as result:  
> ![Screenshot_2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/4/747764d13aad1e82263273c4bb0b9598df74d3ef.png)

Try taking out the brackets

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [31 May 2022 16:26 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/18 "2022-05-31T16:26:22Z")

</div>

Why do you have two outputs in the `function` node? You are only sending one output msg.  
Have you read about [multiple outputs in a function node](https://nodered.org/docs/user-guide/writing-functions#multiple-outputs) in the documentation?

---

<div class="post-metadata">

**Author:** ![BearGrillz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/beargrillz/32/62000_2.png) [@BearGrillz](https://discourse.nodered.org/u/BearGrillz)\
**Post date:** [31 May 2022 16:34 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/19 "2022-05-31T16:34:09Z")

</div>

Yes.. this simply was the problem. I through that I needed one output for each node that had to recieve the message. Thanks a lot for the help

---

<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:** [14 June 2022 16:34 UTC](https://discourse.nodered.org/t/debug-node-dont-show-output/63141/20 "2022-06-14T16:34:59Z")

</div>

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