Mysql fix (#886)

* Check if there is a connection before release

Fixes #885
This commit is contained in:
Ben Hardill 2022-02-21 20:08:33 +00:00 committed by GitHub
parent 5c333db0dd
commit 87e50f2b76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -114,7 +114,9 @@ module.exports = function(RED) {
//console.log("query:",msg.topic);
node.mydbConfig.pool.getConnection(function (err, conn) {
if (err) {
conn.release()
if (conn) {
conn.release()
}
status = { fill: "red", shape: "ring", text: RED._("mysql.status.error") + ": " + err.code };
node.status(status);
node.error(err, msg);