From e7f6549cb6ab35e012289934b64608e5ca273570 Mon Sep 17 00:00:00 2001 From: Stephen McLaughlin <44235289+Steve-Mcl@users.noreply.github.com> Date: Mon, 9 May 2022 16:37:25 +0100 Subject: [PATCH] Remove unnecessary call to `clientRemoveListeners` Also, merge the non JSDOC comment into the JSDOC comment --- .../@node-red/nodes/core/network/10-mqtt.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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 cca28fde1..13d724ed9 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 @@ -922,19 +922,14 @@ module.exports = function(RED) { node.on('close', function(done) { node.disconnect(function() { - if(node.client) { - node._clientRemoveListeners(); - } done(); }); }); - // Helper functions to track the event listners we add to the - // client. The mqtt client also uses it own set of listeners - // so we can't use removeAllListeners() wothout breaking it - /** - * Add an event handler to the MQTT.js client + * Add event handlers to the MQTT.js client and track them so that + * we do not remove any handlers that the MQTT client uses internally. + * Use {@link node._clientRemoveListeners `node._clientRemoveListeners`} to remove handlers * @param {string} event The name of the event * @param {function} handler The handler for this event */