code: function handleDisconnect() {
      _connection = _mysql.createConnection(_dbConfig);
  
      _connection.connect(function (err) {
          if (err) {
              console.log('error when connecting to db:', err);
              setTimeout(handleDisconnect, 2000);
          }
      });
  
      _connection.on('error', function (err) {
          console.log('db error', err);
          if (err.code === 'PROTOCOL_CONNECTION_LOST') {
              handleDisconnect();
          } else {
              throw err;
          }
      });
  }
docs: Pool singleton 
  Handling connection disconnects, as defined here: https://github.com/felixge/node-mysql