NodeJS still “work” even if it can't perfom any query

168
January 20, 2018, at 05:19 AM

I'm developing an application which try to perform some interactions with MySQL.
The strange behaviour is that at one point insert or update commands are no longer performed, but the application does not throw exceptions.
I'm using createPool to manage many connections at a time and I didn't change its default connectionLimit (I'll increase it as soon as possible). Is possible that this default value represents the cause of my issue? What happens if I exceed the connectionLimit?

Any comment on code quality is accepted!

Constructor:

function MySQLHandler(connectionParams, logger) {
  if(!connectionParams) {
    throw new Error("connectionParams is null");
  }
  if(!connectionParams.host || !connectionParams.user || !connectionParams.password || !connectionParams.database) {
    throw new Error("connectionParams not properly setted");
  }
  this.connectionParams = connectionParams;
  this.mysqlConn = mysql.createPool({
        host: this.connectionParams.host,
        user: this.connectionParams.user,
        password: this.connectionParams.password,
        database: this.connectionParams.database
    });
  this.logger = logger;
}

All the functions call this:

MySQLHandler.prototype.query = function (queryString, params, callback) {
  this.logger.log(queryString);
  let _logger = this.logger;
  this.mysqlConn.getConnection(
    function(err, connection) {
      if(err) {
        _logger.error(err);
        return callback(err, null);
      }
      connection.query(queryString, params, function(err, success) {
        connection.release();
        if(err) {
          _logger.error(err);
          return callback(err, null);
        }
        return callback(null, success);
      });
    }
  );
};

Thanks!

READ ALSO
Define koa-router nested routes w/ prefixes

Define koa-router nested routes w/ prefixes

I'm trying to define different routes using koa-router and I'm having a hellova time getting it working

215
What does “error code 13” mean in the Node package Request?

What does “error code 13” mean in the Node package Request?

I'm using a node server that uses Request to hit a different serverThe servers are in the same internal environment and have no connection restrictions, such as firewall or auth

190
how to properly authenticate Node.js app using activedirectory / ldapjs module?

how to properly authenticate Node.js app using activedirectory / ldapjs module?

I need to authenticate my Nodejs app against Active Directory

680
Initiate data transfers from Server => Client?

Initiate data transfers from Server => Client?

i want to build a server app in node/express which receives requests from one client and sends information to another client, maybe somehow similar to this:

170