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

Merge pull request #3869 from Steve-Mcl/fix-mqtt-birth-bad-topic-crash

Prevent invalid mqtt birth topic crashing node-red
This commit is contained in:
Nick O'Leary 2022-09-12 19:17:43 +01:00 committed by GitHub
commit 5b7e84c1b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -997,14 +997,21 @@ 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 {
node.error(err, msg)
}
})
} else { } else {
const error = new Error(RED._("mqtt.errors.invalid-topic")); const error = new Error(RED._("mqtt.errors.invalid-topic"))
error.warn = true; error.warn = true
done(error); if (done) {
done(error)
} else {
node.warn(error, msg)
}
} }
} }
}; };