Skip to content

Terminate a reserved connection released while ending - #1262

Open
whoekage wants to merge 1 commit into
porsager:masterfrom
whoekage:fix/release-after-end
Open

whoekage wants to merge 1 commit into
porsager:masterfrom
whoekage:fix/release-after-end

Conversation

@whoekage

Copy link
Copy Markdown

Fixes #1261

A reserved connection released while the pool is ending was returned to the pool via onopen(c), so Connection.end() kept waiting for it and sql.end() never resolved. release() now terminates the connection when ending is set, and returns it to the pool otherwise as before.

Adds a test that reserves a connection, calls sql.end(), releases the connection afterwards and awaits end().

Verified with the full npm test (esm, cjs, deno) on Node 24 / PostgreSQL 17 in a container replicating the CI workflow (PostgreSQL from pgdg with tests/pg_hba.conf, ssl, wal_level = logical, a second PostgreSQL on 5433):

  • with this change: 3/3 runs clean, 795 passed
  • master with only the new test: the new test times out and the process does not exit
  • pristine master: 2 of 3 runs crash with an unrelated CONNECTION_ENDED unhandled rejection, so that one is pre-existing

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

Successfully merging this pull request may close these issues.

sql.end() never resolves when a reserved connection is released after end() was called

1 participant