-
-
Save brianc/5090658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async'); | |
var pg = require('pg'); | |
var connString = "postgres://postgres@localhost/template1"; | |
// attempt 1 - all ok | |
pg.connect(connString, function(err, client, done) { | |
// this function has a .length of 3 ... therefore done is defined | |
console.log('1) Connected ok'); | |
done(); | |
// pg.end(); | |
}); | |
// attempt 2 - not ok | |
async.waterfall( | |
[ | |
function(callback) { | |
pg.connect(connString, function(err, client, done){ | |
callback(err, client, done); | |
}); | |
}, | |
function(client, done, callback) { | |
console.log('2) Connected ok'); | |
// done is defined (but is actually the callback) | |
done(); | |
callback(); // bang! | |
} | |
], | |
function(err) { | |
console.log('3'); | |
// pg.end(); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment