Hi guys! Could you please explain to me is it ok to have connection status "sleeping" on SQL server after querying DB with node-mssql
I have this simple method:
async queryDatabase(queryOption) {
try {
// const pool = new sql.ConnectionPool(this.getConfigCsdb());
let connection = await pool.connect(this.getConfigCsdb());
let result = await connection.request().query(queryOption);
result = result['recordset'][0][''];
return result;
} catch (e) {
throw e;
} finally {
await connection.close();
}
}
Which works perfectly but want to confirm that it closes a connection.
After querying Database, using EXEC sp_who2;
I see the connection bridge visible in the list of processes:
sleeping Alexanders-MacBook-Pro-3.local node-mssql
when I running query I'm observing status to be changed to "RUNNABLE" and after finishing it becomes "sleeping".
Should it be like that or it should vanish at all from the list of connection shown in EXEC sp_who2;
?
Instead of this
mssql.ConnectionPool(config, err => {
console.log(err);
Try like this:
mssql.ConnectionPool(config)
.then((result) => {})
.catch((reason) => {});
.catch((reason) => {
console.error(reason);
});
dhensby on master
Update changelog for v5 Merge pull request #796 from dh… (compare)