Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not close connection without an exception #2982

Open
yhojann-cl opened this issue May 20, 2023 · 1 comment
Open

Can not close connection without an exception #2982

yhojann-cl opened this issue May 20, 2023 · 1 comment

Comments

@yhojann-cl
Copy link

I try end a connection when end all tasks, by example:

const { Client } = require('pg');

const client = new Client({ .... });

client.connect()
.then(() => client.query('SELECT 1'))
.then(() => client.end());

The results is:

user@pc:~/project$ npm start

> test@1.0.0
> node index.js

(node:293246) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
/home/user/project/node_modules/pg/lib/client.js:132
      const error = this._ending ? new Error('Connection terminated') : new Error('Connection terminated unexpectedly')
                                   ^
Error: Connection terminated
    at Connection.<anonymous> (/home/user/project/node_modules/pg/lib/client.js:132:36)
    at Object.onceWrapper (node:events:627:28)
    at Connection.emit (node:events:525:35)
    at Socket.<anonymous> (/home/user/project/node_modules/pg/lib/connection.js:63:12)
    at Socket.emit (node:events:513:28)
    at TCP.<anonymous> (node:net:313:12)

Node.js v18.12.1

The versions:

user@pc:~/project$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy
user@pc:~/project$ cat package.json | grep pg
    "pg": "^8.11.0",
user@pc:~/project$ node -v
v18.12.1

PostgreSQL version: 12.14.

@jorroll
Copy link

jorroll commented Oct 27, 2023

Probably a duplicate of #1833

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants