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.

Idle connections not being closed by the pool

See original GitHub issue

Based on the docs quick example, I am trying to run a simple query as follows:

const sql = require('mssql')

(async () => {
    try {
        const pool = await sql.connect('mssql://username:password@localhost/database')
        const result = await sql.query`select * from mytable where id = ${value}`
        console.dir(result)
    } catch (err) {
        // ... error checks
    }
})();

After logging the results, the process remains stucked until I press CTRL+C.

The problem is happening in the await sql.query part - it is returning a promise that seems to resolve, so I cannot figure out what is happening and why the process do not finish and keeps waiting for something.

Node 7.9.0 node-mssql 4.0.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:36

github_iconTop GitHub Comments

7reactions
Danieluscommented, Feb 6, 2018

I have the same problem with the 4.10 version. I am using the connection pool when triggering a good amount of async queries. And after I return the results from the db, I explicitly close the connection pool but still the connections used remain active and the MSSQL server shows all the unclosed connection. For a heavy use, this makes the Db server to reach the max available connections and the Node.JS server can not connect anymore .

Is there any fix I can use?

3reactions
patriksimekcommented, Apr 25, 2017

Fixed in 4.0.4. Anyway, the fix doesn’t close the process when all connections are closed. You need to explicitly call pool.close().

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are my database pool connections not being released ...
This would indicate that idle pool connections should be released after ten minutes. Checks are made not less than ten minutes apart to...
Read more >
jdbc - Idle connections are not closed - Stack Overflow
I deploy Keycloak server app (based on WildFly 10.0.0.Final) to Pivotal Cloud Foundry and use ClearDB service as relational database.
Read more >
Idle connections are not closed - JBoss.org
Hi all,. I deploy Keycloak server app (based on WildFly 10.0.0.Final) to Cloud Foundry and use ClearDB service as relational database.
Read more >
JMS Connection Settings/Information and how to debug ...
Resolution · the connection has been idle for too long (controlled by io.jmsConnectionCacheMaxIdleTime cluster property) 5 minutes · the ...
Read more >
How to deal with closed connections in database pool
When a connection is detected as not being used for such time, the connection is automatically closed at the server side, causing mule...
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