From 2c5cc5f70c46b386a0374aa4cff677983c6f83c1 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 8 Apr 2021 17:07:23 +0100 Subject: [PATCH] Fixup mysql node done calls --- storage/mysql/68-mysql.js | 8 +++++--- storage/mysql/package.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/storage/mysql/68-mysql.js b/storage/mysql/68-mysql.js index a04b9805..df425548 100644 --- a/storage/mysql/68-mysql.js +++ b/storage/mysql/68-mysql.js @@ -124,6 +124,7 @@ module.exports = function(RED) { }); node.on("input", function(msg, send, done) { + send = send || function() { node.send.apply(node,arguments) }; if (node.mydbConfig.connected) { if (typeof msg.topic === 'string') { //console.log("query:",msg.topic); @@ -157,23 +158,24 @@ module.exports = function(RED) { msg.payload = rows.map(v => Object.assign({}, v)); } else { msg.payload = rows; } - node.send(msg); + send(msg); status = {fill:"green",shape:"dot",text:"OK"}; node.status(status); - done(); } + done(); // if (node.mydbConfig.pool._freeConnections.indexOf(node.mydbConfig.connection) === -1) { // node.mydbConfig.connection.release(); // } }); } else { - if (typeof msg.topic !== 'string') { node.error("msg.topic : the query is not defined as a string"); } + if (typeof msg.topic !== 'string') { node.error("msg.topic : the query is not defined as a string"); done(); } } } else { node.error("Database not connected",msg); status = {fill:"red",shape:"ring",text:"not yet connected"}; + done(); } if (!busy) { busy = true; diff --git a/storage/mysql/package.json b/storage/mysql/package.json index cba9efdb..fdeedac3 100644 --- a/storage/mysql/package.json +++ b/storage/mysql/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-mysql", - "version": "0.1.6", + "version": "0.1.7", "description": "A Node-RED node to read and write to a MySQL database", "dependencies": { "mysql": "^2.18.1"