Digged some more, and it seems to be affected by link in/out nodes. When function node use return {reset: 1}
, it automagically adds _msgid prop. When it goes through link node, _event prop is added.
Seems like queue node can handle msg with reset, _msgid and _event. But when I try the same with flush, _msgid and _event, it treats it as both a flush control message and a new message. This removes the flush prop, but keeps _msgid and _event. Here is a simplified example:
[
{
"id": "afd7119ab90da785",
"type": "inject",
"z": "a7674a4aaf8a3c64",
"name": "",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 1390,
"y": 980,
"wires": [
[
"bd046bd14e8ad79a"
]
]
},
{
"id": "bd046bd14e8ad79a",
"type": "function",
"z": "a7674a4aaf8a3c64",
"name": "flush",
"func": "// reset any leftover in previous queue\nreturn { flush: 1 };",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1510,
"y": 980,
"wires": [
[
"1a5fb9a9de620724",
"9ae07de9afcd7ef9"
]
]
},
{
"id": "afa13d8bc425b20b",
"type": "link in",
"z": "a7674a4aaf8a3c64",
"name": "link in 10",
"links": [
"1a5fb9a9de620724"
],
"x": 1855,
"y": 980,
"wires": [
[
"7cd67bbf79c1dcad",
"59bf2547ebe2d557"
]
]
},
{
"id": "1a5fb9a9de620724",
"type": "link out",
"z": "a7674a4aaf8a3c64",
"name": "link out 6",
"mode": "link",
"links": [
"afa13d8bc425b20b"
],
"x": 1615,
"y": 980,
"wires": []
},
{
"id": "9ae07de9afcd7ef9",
"type": "debug",
"z": "a7674a4aaf8a3c64",
"name": "debug 1: _msgid added",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1710,
"y": 1020,
"wires": []
},
{
"id": "7cd67bbf79c1dcad",
"type": "delay",
"z": "a7674a4aaf8a3c64",
"name": "queue",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "60",
"rateUnits": "minute",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 2110,
"y": 980,
"wires": [
[
"8ddc534d989cc697"
]
]
},
{
"id": "59bf2547ebe2d557",
"type": "debug",
"z": "a7674a4aaf8a3c64",
"name": "debug 2: _evemt added",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 2030,
"y": 1020,
"wires": []
},
{
"id": "91a80240032f6b46",
"type": "inject",
"z": "a7674a4aaf8a3c64",
"name": "",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 1390,
"y": 1080,
"wires": [
[
"1729cb0bc398109f"
]
]
},
{
"id": "1729cb0bc398109f",
"type": "function",
"z": "a7674a4aaf8a3c64",
"name": "flush",
"func": "// reset any leftover in previous queue\nreturn { flush: 1 };",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1510,
"y": 1080,
"wires": [
[
"ecbc8660ad045e8a",
"97934838227f3705"
]
]
},
{
"id": "ecbc8660ad045e8a",
"type": "debug",
"z": "a7674a4aaf8a3c64",
"name": "debug 1: _msgid added",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1710,
"y": 1120,
"wires": []
},
{
"id": "97934838227f3705",
"type": "delay",
"z": "a7674a4aaf8a3c64",
"name": "queue",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "60",
"rateUnits": "minute",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 2110,
"y": 1080,
"wires": [
[
"65c1572afd9a258f"
]
]
},
{
"id": "65c1572afd9a258f",
"type": "debug",
"z": "a7674a4aaf8a3c64",
"name": "queue output: none",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 2270,
"y": 1080,
"wires": []
},
{
"id": "8ddc534d989cc697",
"type": "debug",
"z": "a7674a4aaf8a3c64",
"name": "queue output: ghost message",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 2310,
"y": 980,
"wires": []
}
]
Seems like queue node has a bug that treats control messages with _event prop as both control message and a new message for the queue?
Temp fix for me is to always add function node before queue node with this code:
const isControlMessage = msg.flush != null || msg.reset != null;
const hasEvent = msg._event != null;
if (isControlMessage && hasEvent) {
delete msg._event;
}
return msg;