Skip to content

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

@TheFarmer1

Description

@TheFarmer1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions