Workflow with sub workflow and node code run forever (new n8n v2)

Describe the problem/error/question

I have a workflow with sub workflow and node code. If I execute workflow manually, it will run fine. But when I use another workflow with MCP and use that workflow as tool, it will run forever.

I tried to change node code with node set and it run fine, so I guess the problem is with sub workflow and node code in new n8n version

What is the error message (if any)?

Nothing, it just run forever without error message.

Please share your workflow

Sub workflow:
{
  "nodes": [
    {
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      name: \"username\"\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -496,
        -272
      ],
      "id": "ea60a9b3-cc28-4ce0-b2bb-817cdbe5cf67",
      "name": "Code2",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "Người yêu cầu"
            },
            {
              "name": "Họ tên người yêu cầu"
            },
            {
              "name": "Bộ phận"
            },
            {
              "name": "Vị trí công việc"
            },
            {
              "name": "IT tiếp nhận yêu cầu"
            },
            {
              "name": "Chi tiết lỗi"
            },
            {
              "name": "Vùng miền"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -768,
        -272
      ],
      "id": "7d50ba91-5486-431e-b398-d1870a740aca",
      "name": "When Executed by Another Workflow",
      "executeOnce": false
    }
  ],
  "connections": {
    "Code2": {
      "main": [
        []
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Code2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "instanceId": "1eb38babc8a8a45a31824b994b841421a7c46b5a123ae069344c5034178393e9"
  }
}


Main workflow:
{
  "nodes": [
    {
      "parameters": {
        "path": "fb567e7b-5762-4dca-b6d7-87eb744de243"
      },
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "typeVersion": 1,
      "position": [
        240,
        -224
      ],
      "id": "36c81fdb-a41a-4bc1-9587-3e45503d6890",
      "name": "MCP Server Trigger",
      "webhookId": "fb567e7b-5762-4dca-b6d7-87eb744de243"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "JbeMJqGBvkqzMpY1",
          "mode": "list",
          "cachedResultUrl": "/workflow/JbeMJqGBvkqzMpY1",
          "cachedResultName": "sucomang"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "Người yêu cầu": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Ng__i_y_u_c_u', ``, 'string') }}",
            "Họ tên người yêu cầu": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('H__t_n_ng__i_y_u_c_u', ``, 'string') }}",
            "Bộ phận": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('B__ph_n', ``, 'string') }}",
            "Vị trí công việc": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('V__tr__c_ng_vi_c', ``, 'string') }}",
            "IT tiếp nhận yêu cầu": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('IT_ti_p_nh_n_y_u_c_u', ``, 'string') }}",
            "Chi tiết lỗi": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Chi_ti_t_l_i', ``, 'string') }}",
            "Vùng miền": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('V_ng_mi_n', ``, 'string') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Người yêu cầu",
              "displayName": "Người yêu cầu",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "Họ tên người yêu cầu",
              "displayName": "Họ tên người yêu cầu",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "Bộ phận",
              "displayName": "Bộ phận",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "Vị trí công việc",
              "displayName": "Vị trí công việc",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "IT tiếp nhận yêu cầu",
              "displayName": "IT tiếp nhận yêu cầu",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "Chi tiết lỗi",
              "displayName": "Chi tiết lỗi",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "Vùng miền",
              "displayName": "Vùng miền",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        32,
        48
      ],
      "id": "b0159153-0d98-4504-ba15-6c7f85e7b6f7",
      "name": "call su co mang"
    }
  ],
  "connections": {
    "call su co mang": {
      "ai_tool": [
        [
          {
            "node": "MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "1eb38babc8a8a45a31824b994b841421a7c46b5a123ae069344c5034178393e9"
  }
}

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 2.1.4
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: debian 12

It worked fine in n8n v1.