diff --git a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js index 50b1d690f..e87a4c7ad 100644 --- a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js +++ b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js @@ -997,14 +997,21 @@ module.exports = function(RED) { } if (topicOK) { - node.client.publish(msg.topic, msg.payload, options, function(err) { - done && done(err); - return - }); + node.client.publish(msg.topic, msg.payload, options, function (err) { + if (done) { + done(err) + } else { + node.error(err, msg) + } + }) } else { - const error = new Error(RED._("mqtt.errors.invalid-topic")); - error.warn = true; - done(error); + const error = new Error(RED._("mqtt.errors.invalid-topic")) + error.warn = true + if (done) { + done(error) + } else { + node.warn(error, msg) + } } } };