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.

Query ends, but no callback

See original GitHub issue

I found a class of queries where when I run them, and they end (I’m looking in the processlist of the database) they never return any value, error, or “end” event.

This query checks if a column has all NULL values, by checking if at least one row is not NULL. If the column has all NULL values, this query never ends.

SELECT 1 FROM table WHERE column IS NOT NULL LIMIT 1

I wrapped the db query to be a promise, as well as added an “on end” callback:

  query(rawSql: string, values: any[][] = []): Promise<any[]> {
    const that = this;
    return new Promise((resolve, reject) => {
      const query = this.db.query(rawSql, values, function (err: MysqlError | null, res?: any) {
        if (err) {
            reject(err);
          } else {
            resolve(res);
          }
      });

      query.on('end', () => console.log("end"));
    });
  }

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
bugfixmancommented, Apr 9, 2020

Me too occurred this error. I have 3 queries. Two queries insert and update executes in the transaction. And select query will be executed after that the transaction is completed.

After has been executed about 10 queries the function query will not called the callback. No any errors. Just the callback is not executed. Only reload the nodeJs app could help fix a bug. But after will made 10 queries the callback will not called. Have any idea?

Sorry. I’m not native speaker. I hope that not made too much mistakes.

0reactions
jarikoffcommented, Dec 6, 2021

@dougwilson Small update: once i set queueLimit: conncetionLimit - 1 to force error if queue > than possible connections - everything works good except error Queue limit reached. Expected behavior - if trying to get connections more than available - wait for released one instead of locking for no reason. I hope it will help you to make it work 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

MySQL Node.js Query Ends, no Callback - Stack Overflow
I understand how this will always get a result, but, this is much more expensive time-wise, as the other method is negation based...
Read more >
Developers - Query ends, but no callback - - Bountysource
Query ends, but no callback. ... This query checks if a column has all NULL values, by checking if at least one row...
Read more >
Connector/Node.js Callback API - MariaDB Knowledge Base
end : Emits when the query ends (no parameter). Sends query to the database with a Callback function to call when done. In...
Read more >
Queries - Redux Toolkit
If the query callback needs additional data to generate the URL, ... This will be true for the first request fired off, but...
Read more >
node-mssql | Microsoft SQL Server client for Node.js
on('finish', () => { // ... }) query (command, [callback]). Execute the SQL command. To execute commands like create procedure or ...
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