In January 2022 - I had the following flow, using a function Node to get information about a YouTube video. It uses the youtube-dl-exec library.
The function code was quite simple:
const myTimeout = setTimeout(NoReturn, 5000);
youtubeDlExec(msg.payload, {dumpSingleJson: true}).then(output => {
msg.payload = output;
clearTimeout(myTimeout);
node.send(msg);
node.done();
});
function NoReturn(){
msg.payload = "No response";
node.send(msg);
node.done();
}
In case a wrong URL was specified - I became - as expected a "No response" message.
Now NR crashes complete. ... and I don't know why.
I tried to change the function code - to use try... , catch ... . But nothing helps.
I have update NR and this library to the newest version.
If a correct URL is provided - the function works well. So what can I do make this function resistent against wrong inputs without crashing NR.??
Here is the complete flow:
[
{
"id": "6452b757c45baa7c",
"type": "function",
"z": "7fd8fff652f013f7",
"name": "youtube-dl-exec",
"func": "const myTimeout = setTimeout(NoReturn, 5000);\n\nyoutubeDlExec(msg.payload, {dumpSingleJson: true}).then(output => {\n msg.payload = output;\n clearTimeout(myTimeout);\n node.send(msg);\n node.done();\n });\n\n\nfunction NoReturn(){\n msg.payload = \"No response\";\n node.send(msg);\n node.done();\n}\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [
{
"var": "youtubeDlExec",
"module": "youtube-dl-exec"
}
],
"x": 500,
"y": 1700,
"wires": [
[
"68d5040203c27b4d"
]
]
},
{
"id": "6c856e483f45a597",
"type": "inject",
"z": "7fd8fff652f013f7",
"name": "6xKWiCMKKJg",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "https://www.youtube.com/watch?v=6xKWiCMKKJg",
"payloadType": "str",
"x": 300,
"y": 1700,
"wires": [
[
"6452b757c45baa7c"
]
]
},
{
"id": "68d5040203c27b4d",
"type": "debug",
"z": "7fd8fff652f013f7",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 710,
"y": 1700,
"wires": []
},
{
"id": "9904e080ec7c54de",
"type": "inject",
"z": "7fd8fff652f013f7",
"name": "Err6xKWiCMKKJg",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "https://www.youtube.com/watch?v=Err6xKWiCMKKJg",
"payloadType": "str",
"x": 310,
"y": 1660,
"wires": [
[
"6452b757c45baa7c"
]
]
}
]
So - OK I updated all NR - but what has so fundamentally changed - that this function node is able to crash NR?
The last version when it didn't crash was 2.1.4 or earlier.