# Strange behaviour

**URL:** https://discourse.nodered.org/t/strange-behaviour/100809
**Category:** General
**Created:** [20 April 2026 13:38 UTC](https://discourse.nodered.org/t/strange-behaviour/100809 "2026-04-20T13:38:39Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)
#### Post date: [20 April 2026 13:38 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/1 "2026-04-20T13:38:39Z")

</div>

Here is a simple flow to use [carbone.io](http://carbone.io) template  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/3/a3ad488a15df6691a101e977c8078885cc8ee9be.png)

the first inject node contains data

```auto
 {
     "entetes": [
         {
             "hdr": "col 1",
             "valeur": "Colonne 1"
         },
         {
             "hdr": "col 2",
             "valeur": "Colonne 2"
         },
         {
             "hdr": "col 3",
             "valeur": "Colonne 3"
         }
     ],
     "data": [
         {
             "hdr": [
                 {
                     "hdr": "col 1",
                     "valeur": "A 1"
                 },
                 {
                     "hdr": "col 2",
                     "valeur": "A 2"
                 },
                 {
                     "hdr": "col 3",
                     "valeur": "A 3"
                 }
             ]
         },
         {
             "hdr": [
                 {
                     "hdr": "col 1",
                     "valeur": "B 1"
                 },
                 {
                     "hdr": "col 2",
                     "valeur": "B 2"
                 },
                 {
                     "hdr": "col 3",
                     "valeur": "B 3"
                 }
             ]
         },
         {
             "hdr": [
                 {
                     "hdr": "col 1",
                     "valeur": "C 1"
                 },
                 {
                     "hdr": "col 2",
                     "valeur": "C 2"
                 },
                 {
                     "hdr": "col 3",
                     "valeur": "C 3"
                 }
             ]
         }
     ]
 }

```

in output, there is a buffer with 12510 bytes, and the conversion with [carbone.io](http://carbone.io) is ok  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b28e8a19ce9f91b3e86d5d80789a7ddb8752c946.png)

the second inject node does not contain data. But data are set in the function node

```auto
 const obj = {
     entetes:[
         {hdr:"col 1",valeur:"Colonne 1"},
         {hdr:"col 2",valeur:"Colonne 2"},
         {hdr:"col 3",valeur:"Colonne 3"}
     ],
     "data":[
         {hdr:[
             {hdr:"col 1",valeur:"A 1"},
             {hdr:"col 2",valeur:"A 2"},
             {hdr:"col 3",valeur:"A 3"}
         ]},
         {hdr:[
             {hdr:"col 1",valeur:"B 1"},
             {hdr:"col 2",valeur:"B 2"},
             {hdr:"col 3",valeur:"B 3"}
         ]},
         {hdr:[
             {hdr:"col 1",valeur:"C 1"},
             {hdr:"col 2",valeur:"C 2"},
             {hdr:"col 3",valeur:"C 3"}
         ]}
     ]
 };
 msg.payload = obj;
 return msg;

```

and now, the output is a buffer with 12044 bytes, and of course, the conversion with [carbone.io](http://carbone.io) does not work.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3ebd394f09f08a09a06c27b0168e444cff270dd6.png)

Any idea ? I am totally lost ! I do not understand why the same data provided in tow different ways does not give the same result !

Thanks for your help

Here is the complete flow

```auto
[
    {
        "id": "22f7a47b705ecce9",
        "type": "subflow",
        "name": "carbone.io",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 360,
                "y": 220,
                "wires": [
                    {
                        "id": "86a74d51bfadf18d"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 840,
                "y": 220,
                "wires": [
                    {
                        "id": "bec126f7ce06bed5",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "86a74d51bfadf18d",
        "type": "function",
        "z": "22f7a47b705ecce9",
        "name": "carbone.io",
        "func": "const carbone = global.get('carbone');\nlet donnees = msg.payload;\nconst template = msg.template;\n\n//carbone.render('.node-red/node_modules/carbone/examples/simple.docx', data, function (err, result) {\ncarbone.render(template, donnees, function (err, result) {\n if (err) {\n msg.payload = err;\n node.send(msg);\n console.log(err)\n return msg;\n }\n // write the result\n console.log(\"resultat \",result);\n msg.payload = result;\n node.send(msg);\n});\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 490,
        "y": 220,
        "wires": [
            [
                "bec126f7ce06bed5"
            ]
        ]
    },
    {
        "id": "bec126f7ce06bed5",
        "type": "file",
        "z": "22f7a47b705ecce9",
        "name": "",
        "filename": "filename",
        "filenameType": "msg",
        "appendNewline": false,
        "createDir": false,
        "overwriteFile": "true",
        "encoding": "none",
        "x": 700,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "61659a935ce4e0e3",
        "type": "comment",
        "z": "22f7a47b705ecce9",
        "name": "Contenu du msg",
        "info": "msg.payload : data\nmsg.template : template\nmsg.filename : filename",
        "x": 640,
        "y": 160,
        "wires": []
    },
    {
        "id": "d3fdf49a4cdea52c",
        "type": "subflow:22f7a47b705ecce9",
        "z": "d09f90d38227a234",
        "g": "4566950462049265",
        "name": "",
        "x": 670,
        "y": 680,
        "wires": [
            [
                "d6d9644d034ef075"
            ]
        ]
    },
    {
        "id": "55092a8cda98d291",
        "type": "inject",
        "z": "d09f90d38227a234",
        "g": "4566950462049265",
        "name": "with data",
        "props": [
            {
                "p": "template",
                "v": "C:\\Users\\Serge\\Documents\\#04 DB_SCENO\\Modeles\\carboneNomenclature.docx",
                "vt": "str"
            },
            {
                "p": "filename",
                "v": "C:\\Users\\Serge\\Documents\\#04 DB_SCENO\\Modeles\\carbone.docx",
                "vt": "str"
            },
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"entetes\":[{\"hdr\":\"col 1\",\"valeur\":\"Colonne 1\"},{\"hdr\":\"col 2\",\"valeur\":\"Colonne 2\"},{\"hdr\":\"col 3\",\"valeur\":\"Colonne 3\"}],\"data\":[{\"hdr\":[{\"hdr\":\"col 1\",\"valeur\":\"A 1\"},{\"hdr\":\"col 2\",\"valeur\":\"A 2\"},{\"hdr\":\"col 3\",\"valeur\":\"A 3\"}]},{\"hdr\":[{\"hdr\":\"col 1\",\"valeur\":\"B 1\"},{\"hdr\":\"col 2\",\"valeur\":\"B 2\"},{\"hdr\":\"col 3\",\"valeur\":\"B 3\"}]},{\"hdr\":[{\"hdr\":\"col 1\",\"valeur\":\"C 1\"},{\"hdr\":\"col 2\",\"valeur\":\"C 2\"},{\"hdr\":\"col 3\",\"valeur\":\"C 3\"}]}]}",
        "payloadType": "json",
        "x": 280,
        "y": 680,
        "wires": [
            [
                "d3fdf49a4cdea52c"
            ]
        ]
    },
    {
        "id": "f0b28ec8f335eb58",
        "type": "function",
        "z": "d09f90d38227a234",
        "g": "4566950462049265",
        "name": "function 3",
        "func": "const obj = {\n entetes:[\n {hdr:\"col 1\",valeur:\"Colonne 1\"},\n {hdr:\"col 2\",valeur:\"Colonne 2\"},\n {hdr:\"col 3\",valeur:\"Colonne 3\"}\n],\n \"data\":[\n {hdr:[\n {hdr:\"col 1\",valeur:\"A 1\"},\n {hdr:\"col 2\",valeur:\"A 2\"},\n {hdr:\"col 3\",valeur:\"A 3\"}\n]},\n {hdr:[\n {hdr:\"col 1\",valeur:\"B 1\"},\n {hdr:\"col 2\",valeur:\"B 2\"},\n {hdr:\"col 3\",valeur:\"B 3\"}\n]},\n {hdr:[\n {hdr:\"col 1\",valeur:\"C 1\"},\n {hdr:\"col 2\",valeur:\"C 2\"},\n {hdr:\"col 3\",valeur:\"C 3\"}\n]}\n ]\n};\nmsg.payload = obj;\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 460,
        "y": 740,
        "wires": [
            [
                "d3fdf49a4cdea52c"
            ]
        ]
    },
    {
        "id": "3c08e9e4db56bae6",
        "type": "inject",
        "z": "d09f90d38227a234",
        "g": "4566950462049265",
        "name": "without data",
        "props": [
            {
                "p": "template",
                "v": "C:\\Users\\Serge\\Documents\\#04 DB_SCENO\\Modeles\\carboneNomenclature.docx",
                "vt": "str"
            },
            {
                "p": "filename",
                "v": "C:\\Users\\Serge\\Documents\\#04 DB_SCENO\\Modeles\\carbone.docx",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 290,
        "y": 740,
        "wires": [
            [
                "f0b28ec8f335eb58"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

### Author: ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)
#### Post date: [20 April 2026 14:39 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/2 "2026-04-20T14:39:31Z")

</div>

You have this :

> [@SergioRT](#):
>
> ```auto
> const obj = {
> entetes:[
> {hdr:"col 1",valeur:"Colonne 1"},
> 
> ```

And not

```auto
 const obj = {
     "entetes":[
         {"hdr":"col 1","valeur":"Colonne 1"},

```

Additional " around the keys. I guess it explains why...

I am not savvy enough to explain the implication in terms of JSON.  
But, the first one is not valid and passed to a json check.

---

<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: [20 April 2026 14:48 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/3 "2026-04-20T14:48:23Z")

</div>

That should not make any difference. In javascript the " are optional around keys without special characters. In the inject node they are required because that is not javascript it is JSON. If you feed the two into a debug node you will see the same output for the two paths.

By all means try adding the quotes in the function node, but it should not change anything.

---

<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: [20 April 2026 14:59 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/4 "2026-04-20T14:59:19Z")

</div>

Did you realise that the subflow will write to the file twice for one input message? In the function node `carbone.io` you have `node.send(msg)` inside each path in the callback, then you have `return msg` at the end. Probably you want to remove the return.

---

<div class="post-metadata">

### Author: ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)
#### Post date: [20 April 2026 15:08 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/5 "2026-04-20T15:08:28Z")

</div>

So :

- with or without quotes, I have the same result as explained Colin
- I removed "return msg" in the subflow "[carbone.io](http://carbone.io)"  
The result is the same !!!

---

<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: [20 April 2026 16:07 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/6 "2026-04-20T16:07:30Z")

</div>

We can't test it properly because the global get is undefined

---

<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: [20 April 2026 16:11 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/7 "2026-04-20T16:11:59Z")

</div>

Change all the backslashes in the filenames to forward slashes, though I don't actually think it is that.

---

<div class="post-metadata">

### Author: ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)
#### Post date: [20 April 2026 16:22 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/8 "2026-04-20T16:22:32Z")

</div>

if you want to test with [carbone.io](http://carbone.io), just install it  
`npm install carbone`

---

<div class="post-metadata">

### Author: ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)
#### Post date: [20 April 2026 16:36 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/9 "2026-04-20T16:36:02Z")

</div>

I found a solution :

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/5/15209c83f89a86bb41634596dbd3ebf373af4937.png)  
I use a node json to convert JSON object to string, and then, in the subflow [carbone.io](http://carbone.io), I use JSON.parse to convert string to object and it works perfectly !

```auto
data = JSON.parse(msg.payload)
...

```

Thanks for your help 🙂

---

<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: [20 April 2026 20:16 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/10 "2026-04-20T20:16:35Z")

</div>

> [@SergioRT](#):
>
> I use a node json to convert JSON object to string

Actually what it is doing is converting the javascript object to a JSON string.

> [@SergioRT](#):
>
> it works perfectly

So converting the object to a JSON string and back to an object fixes it? Weird.

---

<div class="post-metadata">

### Author: ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)
#### Post date: [23 April 2026 12:35 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/11 "2026-04-23T12:35:19Z")

</div>

More precisely, I was able to confirm that providing a JSON string to a JSON node allowed me to obtain a correct and identical result whether using an "Inject" node or a "function" node.

Indeed, I also find this surprising and strange. Nevertheless, it works, and I was able to generate a Word document very efficiently from my JSON data and a relatively simple template.

Whatever, great thanks for your help

---

<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: [23 April 2026 12:55 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/12 "2026-04-23T12:55:43Z")

</div>

Even more precisely, you started with apparently identical javascript objects from an Inject node and a Function node, but feeding those into your subflow yielded different results, so there must be a subtle difference between the two.

You then added a JSON node, which converted both objects to JSON strings, and then used JSON.parse to convert them back to javascript objects and the problem was fixed. Therefore the act of converting the two objects to JSON strings and back to js objects made the two identical.

Probably just adding two JSON nodes in series to the input wire would also have solved the problem.

---

<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: [7 May 2026 12:56 UTC](https://discourse.nodered.org/t/strange-behaviour/100809/13 "2026-05-07T12:56:34Z")

</div>

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