Skip to content

pg.end() doesn't always end the connections #120

@fsateler

Description

@fsateler

Simple testcase:

var opts = {
    "driver": "postgres",
    "host": "localhost",
    "user": "nodetest",
    "password": "password",
    "database": "nodetest"
}


var pg = require('pg');

pg.connect(opts, function(err, client) {
    pg.end();
});

Then executing it:

% time node test_pg.js
^Cnode test_pg.js  2.49s user 0.66s system 0% cpu 14:10.42 total

I halted the program after 14 minutes. If I modify it like this:

var opts = {
    "driver": "postgres",
    "host": "localhost",
    "user": "nodetest",
    "password": "password",
    "database": "nodetest"
}


var pg = require('pg');

pg.connect(opts, function(err, client) {
    client.query('select * from person', function(){
        pg.end();
    });
});

Then it works:

% time node test_pg.js
node test_pg.js  0.12s user 0.02s system 11% cpu 1.142 total

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions