Node not finishing - bug?

I have a node that is returning 2 results. In a function node with just

return items;

I can see them just fine. I want to return only the first result. While I know now it should be

return [ items[0] ];

I first made the mistake to just return

return items[0];

and with that the node never finished executing.

Is that maybe a bug?
At least IMO it should give some better feedback.

@tcurdt this happened to me as well but I think it happens when you do not return something valid, It would be better to show some sort of error. Either way, you can do what you want to do with the example below.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: { item: 'test' }\n  },\n  {\n  json: { item2: 'test2' }\n  }\n]"
      },
      "name": "Data",
      "type": "n8n-nodes-base.function",
      "position": [
        520,
        300
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: items[0].json\n  }\n]\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        670,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like

Yes, that is then probably really a bug. I will try to look into it soon.

1 Like

@jan you can replicate it by running a function that does not return anything.

2 Likes

Thanks a lot! That is very helpful!

Ok got improved:

1 Like

Got released with [email protected]

1 Like