ConnectionPool.release Exception in node js while accessing DB using mssql

1,263 views
Skip to first unread message

chris joe

unread,
Dec 6, 2017, 11:36:44 PM12/6/17
to nodejs
Node.js version: v4.2.6
OS: Linux
Sql server: 2012


I have used node js to connect mssql database server. Data's are inserted into DB continuously 

But we are facing connection pool release exception sometimes.

Find the code snippet and issue in below 

 Code:

    var sql = require('mssql')
   
var dbconfig = {
        server
: 'xxxx',
        database
: 'xxxx',
        user
: 'xxx',
        password
: 'xxx',
        port
: 'xx'
   
};
   
try {
        sql
.close();
       
var connection = sql.connect(dbconfig, function (err) {
   
           
if (err) console.log(err);
   
           
var sqlquery = '';
           
var request = new sql.Request();
           
//query to the database and get the repo value
            sqlquery
= 'select Repo from verylargetable';
            request
.query(sqlquery, function (err, result) {
               
if (err) console.log(err)
               
var repo = result.recordset[0].Repo;
   
               
//query to the database and get the commit value
                sqlquery
= "select Commit from verylargetable where Repo='" + repo + "'";
                request
.query(sqlquery, function (err, result) {
                   
if (err) console.log(err)
                   
var comm = result.recordset[0].Commit;
   
                   
//query to the database and update the table
                    sqlquery
= "UPDATE verylargetable set Repo='" + repo + "', WHERE Comm='" + comm + "'";
                    request
.query(sqlquery, function (err, result) {
                       
if (err) console.log(err)
                        console
.log("record(s) updated");
                   
});
               
});
           
});
       
});
   
}
   
catch (e) {
        console
.log("===========Exception Occurred==========");
        console
.log(e);
        console
.log(new Date().toString());
        console
.log("==========================================================");
   
}


Issue:
    
 TypeError: Cannot read property 'release' of null
 at ConnectionPool.release (/usr/lib/Webhook/node_modules/mssql/lib/base.js:199:14)
 at Request.userCallback (/usr/lib/Webhook/node_modules/mssql/lib/tedious.js:608:25)
 at Request._this.callback (/usr/lib/Webhook/node_modules/tedious/lib/request.js:47:27)
 at Connection.message (/usr/lib/Webhook/node_modules/tedious/lib/connection.js:1401:27)
 at Connection.dispatchEvent (/usr/lib/Webhook/node_modules/tedious/lib/connection.js:687:45)
 at MessageIO.<anonymous> (/usr/lib/Webhook/node_modules/tedious/lib/connection.js:602:18)
 at emitNone (events.js:67:13)
 at MessageIO.emit (events.js:166:7)
 at ReadablePacketStream.<anonymous> (/usr/lib/EJ2Webhook/node_modules/tedious/lib/message-io.js:102:16)
 at emitOne (events.js:77:13)
 at ReadablePacketStream.emit (events.js:169:7)

How to resolve this exception and how to handle exception in query execution?

Tony Mobily

unread,
Dec 12, 2017, 11:17:23 PM12/12/17
to nodejs
Hi,

This looks like a problem with the mssql module itself.

I would watch that bug and see if you can find any hints!

Merc.

Tony Mobily

unread,
Dec 12, 2017, 11:17:23 PM12/12/17
to nodejs
Hi,

Ah, I just noticed YOU are the poster of that bug!

Merc.

On Thursday, 7 December 2017 12:36:44 UTC+8, christopher wrote:
Reply all
Reply to author
Forward
0 new messages