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

Acquire calls do not timeout if pool is drained. #42

Open
TheFarmer1 opened this issue Dec 22, 2016 · 0 comments
Open

Acquire calls do not timeout if pool is drained. #42

TheFarmer1 opened this issue Dec 22, 2016 · 0 comments

Comments

@TheFarmer1
Copy link

The ConnectionPool.drain function clears waiting acquire calls. These acquire calls will hang forever. Instead, the waiting requests should timeout immediately (which doesn't seem possible with Timers) or don't clear them and let them timeout.

An easy way to see this is:

`var poolConfig = {
acquireTimeout: 5000 //sorten the timeout to make the example easier to understand
};

var connectionConfig = {
userName: 'test',
password: 'test',
server: 'bad-server-name',
options: {
appName: 'pool-test',
database: 'test'
}
};

//create the pool
var pool = new ConnectionPool(poolConfig, connectionConfig);

pool.on('error', function(err) {
console.error('Error Event: ' + err.message);
pool.drain();
});

//acquire a connection
pool.acquire(function (err, connection) {
if (err)
// you'll never see this
console.error('Acquire Error: ' + err.message);
});

console.log('done!');`

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