schimaere / node-red-contrib-natsstreaming

NodeRED nodes for nats-streaming
MIT License
5 stars 3 forks source link

error with multiple wires #6

Open ronopitz opened 4 years ago

ronopitz commented 4 years ago

Hi,

when I wired to two nodes behind the nats-streaming-subscibe node. The Node Red environment kills with an error.

The example is very easy. The main problem is to read messages from nats streaming and write a subset to an other channel on the nats server by using the acknowlege node.

logs

16 Apr 11:16:08 - [info] Starting flows
16 Apr 11:16:08 - [debug] red/nodes/flows.start : starting flow : global
16 Apr 11:16:08 - [debug] red/nodes/flows.start : starting flow : 3d592228.01d6ee
16 Apr 11:16:08 - [trace] [flow:global] start flow [global]
16 Apr 11:16:08 - [trace] [flow:global] ------------------|--------------|-----------------
16 Apr 11:16:08 - [trace] [flow:global]  id               | type         | alias
16 Apr 11:16:08 - [trace] [flow:global] ------------------|--------------|-----------------
16 Apr 11:16:08 - [trace] [flow:global]  3e89f199.33c016  | nats-streaming-server |
16 Apr 11:16:08 - [trace] [flow:global] ------------------|--------------|-----------------
16 Apr 11:16:08 - [trace] [flow:3d592228.01d6ee] start flow [3d592228.01d6ee]
16 Apr 11:16:08 - [trace] [flow:3d592228.01d6ee] ------------------|--------------|-----------------
16 Apr 11:16:08 - [trace] [flow:3d592228.01d6ee]  id               | type         | alias
16 Apr 11:16:08 - [trace] [flow:3d592228.01d6ee] ------------------|--------------|-----------------
16 Apr 11:16:08 - [trace] [flow:3d592228.01d6ee]  30482043.d790d8  | nats-streaming-subscribe |    |
16 Apr 11:16:08 - [trace] [flow:3d592228.01d6ee]  5e44e650.021a    | debug        |
16 Apr 11:16:08 - [trace] [flow:3d592228.01d6ee]  241456ed.ac4b12  | no-op        |
16 Apr 11:16:08 - [trace] [flow:3d592228.01d6ee]  1cbb3e3a.473da2  | debug        |
16 Apr 11:16:08 - [trace] [flow:3d592228.01d6ee] ------------------|--------------|-----------------
16 Apr 11:16:08 - [trace] runtime event: {"id":"runtime-state","retain":true}
16 Apr 11:16:08 - [info] Started flows
16 Apr 11:16:09 - [info] [nats-streaming-subscribe:30482043.d790d8] connected
16 Apr 11:16:09 - [info] [nats-streaming-subscribe:30482043.d790d8] subscription is ready
16 Apr 11:16:09 - [red] Uncaught Exception:
16 Apr 11:16:09 - TypeError: Cannot set property 'flags' of undefined
    at URL.onParseComplete (internal/url.js:224:13)
    at URL.set [as href] (internal/url.js:443:7)
    at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:16)
    at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
    at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
    at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
    at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
    at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
    at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
    at clone (/usr/src/node-red/node_modules/clone/clone.js:202:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-red-docker@1.0.4 start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"`
npm ERR! Exit status 1

Flow example

[
    {
        "id": "30482043.d790d8",
        "type": "nats-streaming-subscribe",
        "z": "3d592228.01d6ee",
        "name": "",
        "server": "3e89f199.33c016",
        "channel": "metric",
        "clientID": "metric-store",
        "start": "last_reveived",
        "start_option": "",
        "durable": "",
        "durable_name": "",
        "queue_group": "",
        "queue_group_name": "",
        "autoacknowledge": false,
        "ackwait": "10",
        "rate_limit": true,
        "max_in_flight": "1",
        "x": 150,
        "y": 300,
        "wires": [
            [
                "241456ed.ac4b12"
            ]
        ]
    },
    {
        "id": "5e44e650.021a",
        "type": "debug",
        "z": "3d592228.01d6ee",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 510,
        "y": 280,
        "wires": []
    },
    {
        "id": "241456ed.ac4b12",
        "type": "no-op",
        "z": "3d592228.01d6ee",
        "name": "",
        "x": 350,
        "y": 300,
        "wires": [
            [
                "5e44e650.021a",
                "1cbb3e3a.473da2"
            ]
        ]
    },
    {
        "id": "1cbb3e3a.473da2",
        "type": "debug",
        "z": "3d592228.01d6ee",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 510,
        "y": 320,
        "wires": []
    },
    {
        "id": "3e89f199.33c016",
        "type": "nats-streaming-server",
        "z": "",
        "server": "nats-streaming",
        "port": "4222",
        "cluster": "test-cluster"
    }
]
ronopitz commented 4 years ago

I tried it with node12, but the same issue. NodeRed 1.x with node8 doesn't exists as docker image.

I'm looking for a solution and found https://github.com/node-cache/node-cache/issues/127

Is this an issue for you or for the node-red team?

danroshko commented 4 years ago

May be related to this node-red issue. Apparently adding classes with getters and setters to messages can cause problems when node-red copies them between nodes. One solution could be not sending streaming_msg along with payload at this line. As a quick fix, you can add additional function node after nats-streaming-subscibe node, which removes this streaming_msg property from the message.