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!');`
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!');`