From cbe846cbda75f05180b2c563a633f63b56825aed Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 18 Jul 2026 12:58:57 +0800 Subject: [PATCH] fix: send Sync on error during rows-limited (portal) queries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit handleError was missing the connection.sync() call that handleCommandComplete already has for the rows-limited path. When a query with the rows option hits an ErrorResponse from the server, handleError returns the error to the caller but never sends Sync. The server stays in an extended-query subtransaction waiting for Sync, ReadyForQuery never arrives, and the connection is permanently wedged — every subsequent query on that connection queues forever. handleCommandComplete has had this sync call since rows support was added. handleError simply forgot to do the same. Refs: #3707 --- packages/pg/lib/query.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/pg/lib/query.js b/packages/pg/lib/query.js index 04e1c1d65..e26799d7e 100644 --- a/packages/pg/lib/query.js +++ b/packages/pg/lib/query.js @@ -125,6 +125,12 @@ class Query extends EventEmitter { err = this._canceledDueToError this._canceledDueToError = false } + // send sync to unstick the connection after an error during + // a rows-limited (portal suspension) query; without this, + // the server waits for Sync and ReadyForQuery never arrives. + if (this.rows) { + connection.sync() + } // if callback supplied do not emit error event as uncaught error // events will bubble up to node process if (this.callback) {