Skip to content

end() on pg.Client hangs if connect() fails #2777

Closed
@MasterOdin

Description

@MasterOdin

Given the following code:

const pg = require('pg');
const client = new pg.Client({ host: 'bogushost' });
try {
  await client.connect();
} catch (err) {
  // pass
}
await client.end();

The end() call will hang indefinitely. I've seen this happen with at least ENOTFOUND and ECONNREFUSED errors.

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