Pause()/resume() doesn't work as expected with connection from connectionPool
niranjan1001 opened this issue · 0 comments
Hello, I am trying to run the below code
var ConnectionPool = require('tedious-connection-pool');
var Request = require('tedious').Request;
var poolConfig = {
min: 2,
max: 4,
log: true
};
var connectionConfig = {
userName: 'sa',
password: 'reallyStrongPwd123',
server: 'localhost'
};
//create the pool
var pool = new ConnectionPool(poolConfig, connectionConfig);
pool.on('error', function(err) {
console.error(err);
});
//acquire a connection
pool.acquire(function (err, connection) {
if (err) {
console.error(err);
return;
}
//use the connection as normal
var request = new Request('SELECT * FROM Persons', function(err, rowCount) {
if (err) {
console.error(err);
return;
}
console.log('rowCount: ' + rowCount);
//release the connection back to the pool when finished
connection.release();
});
request.on('row', function(columns) {
request.pause()
// connection.pauseRequest(request)
console.log('value: ' + columns[0].value);
});
connection.execSql(request);
});
Expected Behavior
The expectation is that the request will be paused after reading a row.
Current Behavior
The connection continues to read all the rows instead of pausing the request after reading a row
Possible Fix
The tedious module being used is of older version which doesn't support pause()/resume() functionality. Updating the tedious module version to 2.2.3 in package.json would fix the issue.
Can you please help?