question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

connection.query callback never executed

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:23 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
sidorarescommented, Oct 8, 2015

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

0reactions
Cherviakovcommented, Oct 8, 2015

Another kind of error got on that place:

{ [Error: This socket has been ended by the other party] code: 'EPIPE' }

Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS mysql connection.query callback not logging results ...
1- Have you correctly changed these 4 variable. host: 'host', port: 'port', user: 'user', password: 'pass'. 2- Make sure that your mysql DB ......
Read more >
node-mssql | Microsoft SQL Server client for Node.js
Request; execute; input; output; toReadableStream; pipe; query ... callback(err) - A callback which is called after initial probe connection has established ...
Read more >
Node.js v19.3.0 Documentation
Promise execution tracking; JavaScript embedder API. Class: AsyncResource ... getInfo(query, callback) { this.db.get(query, (err, data) => { this.
Read more >
Query Never Returned (Node.js Cassandra Driver)
After several queries, some queries never return callback and disappear without any information, no error, no log at all. Anyone here had similar...
Read more >
Connector/Node.js Callback API - MariaDB Knowledge Base
Connection: connection.query(sql[, values][, callback]) → Emitter: Executes a query. connection.batch(sql, values[ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found