Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Connection reconnect rejects the next query with a stale ErrorResponse from before the socket closed

Open Beginner friendly
#1,249 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 7 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, nodejs, postgresql
Domain
databases

Research direction

Start in src/connection.js, where connect() and closed() reset buffers and timers but leave query, results and errorResponse set. Reproduce with max: 1, a TCP proxy that drops the ReadyForQuery after an ErrorResponse, then a second query on the same connection. Done when the query after reconnect returns 1 instead of the stale error, and a regression test covers it. The reporter offers to send a PR, so check with them before starting.

Written by the indexing model from the issue text.

Description

Version: 3.4.9 (also present on master as of 2026-10)

What happens

If the server (or a pooler such as pgbouncer) sends an ErrorResponse and then closes the socket before the ReadyForQuery, the connection object keeps query and errorResponse set. closed() and connect() reset buffers and timers but not these. When the same connection object connects again, the startup ReadyForQuery sees the old errorResponse, calls errored(errorResponse) and rejects initial, the first query on the new socket, with the old error. This can happen any time later; we saw it 90 minutes after a pgbouncer outage. The stack of the error points to the query that originally failed, not the one that was rejected.

Reproduction (TCP proxy between client and server)

  1. max: 1. Run sql`select 1/0`.
  2. The proxy forwards the E message, drops the Z behind it, and closes both sockets.
  3. Run sql`select 1`. It rejects with division by zero instead of returning 1.

Fix we apply locally (at the top of connect() in src/connection.js)

query = results = errorResponse = null
result = new Result()

Happy to open a PR with the fix and a test.

Dominant language
JavaScript
Stars
8.7k
Forks
389
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from porsager/postgres

All issues in porsager/postgres

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.