node-red / node-red

Low-code programming for event-driven applications
http://nodered.org
Apache License 2.0
18.93k stars 3.31k forks source link

Loss of links when importing a copy of links into a subflow #4749

Closed GogoVega closed 2 weeks ago

GogoVega commented 3 weeks ago

Current Behavior

Issue described in #4055 and on the forum.

The issue only appears when importing a copy.

node_map[id] is undefined while a console.log shows that the node exists in the object.

(id, node_map, node_map[id])

Capture d’écran 2024-06-04 à 22 08 21

https://github.com/node-red/node-red/blob/61b12f6bbe3169d87637f6841075ff502f8a27e0/packages/node_modules/%40node-red/editor-client/src/js/nodes.js#L2409

Expected Behavior

The links should not separate.

Steps To Reproduce

Import twice the flow below into a subflow. The first import, the links are connected. During the second import (which is a copy), the links are separated.

Example flow

[
    {
        "id": "afbef9d1a7e911fc",
        "type": "inject",
        "z": "4abc8dbde5a2e0fb",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 230,
        "y": 60,
        "wires": [
            [
                "9fdbd0603ad12be7"
            ]
        ]
    },
    {
        "id": "dcde14acf132b58a",
        "type": "debug",
        "z": "4abc8dbde5a2e0fb",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 520,
        "y": 60,
        "wires": []
    },
    {
        "id": "b3b23a6f58dc8ec5",
        "type": "link in",
        "z": "4abc8dbde5a2e0fb",
        "name": "link in 2",
        "links": [
            "9fdbd0603ad12be7"
        ],
        "x": 405,
        "y": 60,
        "wires": [
            [
                "dcde14acf132b58a"
            ]
        ]
    },
    {
        "id": "9fdbd0603ad12be7",
        "type": "link out",
        "z": "4abc8dbde5a2e0fb",
        "name": "link out 2",
        "mode": "link",
        "links": [
            "b3b23a6f58dc8ec5"
        ],
        "x": 345,
        "y": 60,
        "wires": []
    }
]

Environment