Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause()/resume() doesn't work as expected with connection from connectionPool #55

Open
niranjan1001 opened this issue Mar 19, 2019 · 0 comments

Comments

@niranjan1001
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant