Skip to content

Inconsistent done behavior in Split node when streaming #3982

@phoddie

Description

@phoddie

Current Behavior

I am using the Split node with streaming enabled. Passing the same stream of messages, gives a different number of triggers of the Completion node depending on whether the inputs are a string or a buffer.

Expected Behavior

When the message is a stream of strings, it works as expected: 5 messages passed into the streaming split and the completion node triggers five times.

When the message is a stream of buffers, I expect the completion to trigger 5 times. Instead, it triggers 7 times.

Steps To Reproduce

Run the attached flow. It immediately injects a string message that shows the expected behavior. One second later it injects an equivalent binary message that shows the unexpected behavior.

Example flow

[
    {
        "id": "a31797b09a52b301",
        "type": "tab",
        "label": "split2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "ae115e073cce9519",
        "type": "split",
        "z": "a31797b09a52b301",
        "name": "stream !",
        "splt": "!",
        "spltType": "str",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": true,
        "addname": "",
        "x": 560,
        "y": 120,
        "wires": [
            [
                "d65d9d8e1e0f4172"
            ]
        ]
    },
    {
        "id": "30b32897ad6bb48c",
        "type": "split",
        "z": "a31797b09a52b301",
        "name": "length 3",
        "splt": "5",
        "spltType": "len",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 360,
        "y": 120,
        "wires": [
            [
                "ae115e073cce9519"
            ]
        ]
    },
    {
        "id": "2a503ddb59560644",
        "type": "inject",
        "z": "a31797b09a52b301",
        "name": "inject STRING",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "aaa!bbb!ccc!ddd!eee!fff!",
        "payloadType": "str",
        "x": 180,
        "y": 120,
        "wires": [
            [
                "30b32897ad6bb48c"
            ]
        ]
    },
    {
        "id": "8f6530e24663c675",
        "type": "complete",
        "z": "a31797b09a52b301",
        "name": "",
        "scope": [
            "ae115e073cce9519"
        ],
        "uncaught": false,
        "x": 350,
        "y": 220,
        "wires": [
            [
                "3f4b50727a2486df"
            ]
        ]
    },
    {
        "id": "3f4b50727a2486df",
        "type": "change",
        "z": "a31797b09a52b301",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "DONE",
                "pt": "msg",
                "to": "STRING",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 540,
        "y": 220,
        "wires": [
            [
                "d65d9d8e1e0f4172"
            ]
        ]
    },
    {
        "id": "d65d9d8e1e0f4172",
        "type": "debug",
        "z": "a31797b09a52b301",
        "name": "debug 9",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 780,
        "y": 300,
        "wires": []
    },
    {
        "id": "cd5357aefbece598",
        "type": "split",
        "z": "a31797b09a52b301",
        "name": "stream !",
        "splt": "[33]",
        "spltType": "bin",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": true,
        "addname": "",
        "x": 560,
        "y": 360,
        "wires": [
            [
                "d65d9d8e1e0f4172"
            ]
        ]
    },
    {
        "id": "e8f25dba1620c2e8",
        "type": "split",
        "z": "a31797b09a52b301",
        "name": "length 3",
        "splt": "5",
        "spltType": "len",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 360,
        "y": 360,
        "wires": [
            [
                "cd5357aefbece598"
            ]
        ]
    },
    {
        "id": "76d690021d085454",
        "type": "inject",
        "z": "a31797b09a52b301",
        "name": "inject BINARY",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "topic": "",
        "payload": "[97,97,97,33,98,98,98,33,99,99,99,33,100,100,100,33,101,101,101,33,102,102,102,33]",
        "payloadType": "bin",
        "x": 180,
        "y": 360,
        "wires": [
            [
                "e8f25dba1620c2e8"
            ]
        ]
    },
    {
        "id": "c76ab8e918f1174a",
        "type": "complete",
        "z": "a31797b09a52b301",
        "name": "",
        "scope": [
            "cd5357aefbece598"
        ],
        "uncaught": false,
        "x": 350,
        "y": 460,
        "wires": [
            [
                "767185f51d25a77a"
            ]
        ]
    },
    {
        "id": "767185f51d25a77a",
        "type": "change",
        "z": "a31797b09a52b301",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "DONE",
                "pt": "msg",
                "to": "BINARY",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 540,
        "y": 460,
        "wires": [
            [
                "d65d9d8e1e0f4172"
            ]
        ]
    }
]

Environment

  • Node-RED version: v3.0.2
  • Node.js version: v19.2.0
  • npm version: 8.19.3
  • Platform/OS: Darwin 21.6.0 arm64 LE
  • Browser: Chrome Version 108.0.5359.98

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions