1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

fix node-red crash with invalid mqtt birth topic

fixes #3865
This commit is contained in:
Steve-Mcl 2022-09-04 11:08:41 +01:00
parent 5365786386
commit fbde0091de

View File

@ -992,13 +992,20 @@ module.exports = function(RED) {
if (topicOK) { if (topicOK) {
node.client.publish(msg.topic, msg.payload, options, function (err) { node.client.publish(msg.topic, msg.payload, options, function (err) {
done && done(err); if (done) {
return done(err)
});
} else { } else {
const error = new Error(RED._("mqtt.errors.invalid-topic")); node.error(err, msg)
error.warn = true; }
done(error); })
} else {
const error = new Error(RED._("mqtt.errors.invalid-topic"))
error.warn = true
if (done) {
done(error)
} else {
node.warn(error, msg)
}
} }
} }
}; };