Skip to content

Loading…

pg.connect acts on callback in a nonstandard way #223

Closed
ghost opened this Issue · 4 comments

1 participant

@ghost

pg.connect(str, function(err, client) { /* err is null, client is a pg client object */ });

pg.connect(str, function(err) { /* err is not null, and is a pg client object! */ });

When the callback has arity 1, connect binds the client to the first (typically error) argument. Connect shouldn't be sensitive to how many arguments the client is declaring in the callback...

pg 0.8.7 with node 0.8.8

@brianc
Owner

can you write code to reproduce this? That is strange indeed. Looking at the code it doesn't seem apparent where this would be - it might be inside the node-pool library.

@ghost

var pg = require('pg');
var connString = '...';
pg.connect(connString, function(err, client) { console.log(err); });
pg.connect(connString, function(err) { console.log(err); });

if it's a good connection, the first one prints null, and the second one prints a client object.

@brianc
Owner

got it figured out - it's an issue with https://github.com/coopernurse/node-pool

I'll update version of node-pool & submit new version to npm after work.

@ghost

sweet, thanks for looking into it! minor but odd.

@brianc brianc added a commit that referenced this issue
@brianc update version of node-pool closes gh #223
added integration test to catch any future regressions
8b9e97f
@brianc brianc closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.