Node js: mssql [ConnectionError: Connection is closed.] name: 'ConnectionError', message: 'Connection is closed.', code: 'ECONNCLOSED'
<p><strong>i am getting error in npm mssql 3.0.0 with sqlserver 2012</strong></p>

<p>i am creating single page application where i used restful using express .
there are 4 method which executing the query and returning the data to response.
for each method i am opening the connection and closing the connection.</p>

<p>but when savedquery is calling then connection close error occurs.</p>

<p>each method code is similar to savedquery method (copy pasted code only queries are changed) but they are executing savedquery is not executing </p>

<p><strong>{ [ConnectionError: Connection is closed.]
  name: 'ConnectionError',
  message: 'Connection is closed.',
  code: 'ECONNCLOSED' }</strong></p>

<pre><code>var savedquery=function(req,res){
       dbConfig= {
                user: 'XXX',
                password: 'XXXXXXXXXX',
                server: 'localhost', // You can use 'localhost\\instance' to connect to named instance 
                database: 'DEMO_ODS',       
                options: {
                    encrypt: true
                }
            };

        sql.connect(dbConfig).then(function (err) {
                var sqlrequest = new sql.Request();
                sqlrequest.query("SELECT * from SavedQuery").then(function (recordset) {
                    sql.close(function (value) {
                      console.log("connection6 closed");
                    });
                    return res.status(200).send(recordset);

                }).catch(function (err) {
                    console.log(err);
                });
            }).catch(function (err) { 
                console.log(err);
            });
        };
}
</code></pre>