Query ends, but no callback
See original GitHub issueI 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:
- Created 3 years ago
- Comments:18 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@dougwilson Small update: once i set
queueLimit: conncetionLimit - 1
to force error if queue > than possible connections - everything works good except errorQueue 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 😃