node-mysql2: connection.query callback never executed

Hi, I’m working on app which download and process database. After downloading when I try to insert data in mysql on certain rounds program failing silently. I tracked problem to connection.query method from mysql2 library,even though query executed its callback never executed and program just exits.

Sometimes this problem not bother but other time can execute up to 20 times my app and it exits on very same round giving no error at all.

I’m working on Windows 8, node 0.12.7, mysql2 0.15.8.

I can’t see any special about circumstances, it fails on query “USE my dbName” (have to do that several times cause otherwise get mysql error that database not chosen. Using pool = mysql.createPool() from mysql2).

Here is code:

`function addAndUpdateUsers(table,usersData,cb){

//console.log("addAndUpdateUsers");

if(utils.isItemsEmpty(usersData) === true){

    cb(null);

    return;

}

var currentRegistrationDate = Object.keys(usersData)[0];

var users = [];

console.log("before array");

for(var item in usersData[currentRegistrationDate]){

    users.push(usersData[currentRegistrationDate][item]);

}

console.log("before use");

connection.query("USE " + config.dbName, function(err,rows,field){

    if(err) console.log(err);

    console.log("after use");`

I can see log “before use”, but don’t see “after use”.

Ready to give any additional info needed.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 23 (11 by maintainers)

Commits related to this issue

Most upvoted comments

so the process just exits without calling callback? Are you sure there is no process.exit() somewhere?