I am trying to execute a stored procedure on a remote MS sql server from my node application using node-mssql .
Problem : The call seems to be blocking and not asynchronos, since any other request to the application from another client, does not get responded to unless the first request is complete .
sql.connect(config).then(function() {
new sql.Request()
.input('mysp', sql.TVP, tvp)
.execute('spParam1').then(function(recordsets) {
callback(null, recordsets[0]);
}).catch(function(err) {
callback(err, []);
});
}).catch(function(err) {
callback(err, []);
});
The 'callback' mentioned is the function call back expected by the api .
I tried a simple example of
setTimeout(function() {
callback("error.message", []);
}, 60000);
And in this case both clients work, and Node gives back the thread for the 2nd request.
I have tried the example using promises,callbacks and streaming. All end up blocking the I/O.
What am i overlooking here ?
EDIT : Just used a query instead of an 'execute', and it works as expected, without blocking i/o
dbConn.connect().then(function () {
logger.info("sql connection established")
var request = new sql.Request(dbConn);
// request.input('mysp', sql.TVP, tvp)
// .execute("spParam1").then(function (recordSet) {
request.query("WAITFOR DELAY '00:00:22'").then(function(){
dbConn.close();
callback("no data", []);
}).catch(function (err) {
callback(err, []);
logger.error(err)
dbConn.close();
});
}).catch(function (err) {
logger.error(err)
callback(err, []);
});