Skip to content

fix(pg): do not treat Sync as connection ending - #3772

Open
devtechedge wants to merge 1 commit into
brianc:masterfrom
devtechedge:fix/connection-sync-ending-flag
Open

fix(pg): do not treat Sync as connection ending#3772
devtechedge wants to merge 1 commit into
brianc:masterfrom
devtechedge:fix/connection-sync-ending-flag

Conversation

@devtechedge

Copy link
Copy Markdown

Summary

Fixes #3769.

Connection.sync() was setting _ending = true on every extended-query Sync. That flag exists so reportStreamError can ignore ECONNRESET / EPIPE during disconnect. Sync is the protocol barrier after Parse/Bind/Execute, not a disconnect, so after the first parameterized query those socket errors were silently dropped for the rest of the connection lifetime.

With pipeline: true that interacts badly with unexpected pooler/socket teardowns: the normal error path is closed and recovery depends only on the async close/end path, which can leave an in-flight query promise unsettled.

Changes

  • Stop setting _ending in sync(); leave it set only in end() (Terminate) and the connect-timeout teardown path that already sets con._ending = true before destroying the stream.
  • Add unit coverage that Sync leaves _ending false and that ECONNRESET after Sync still emits error (existing disconnect coverage still uses end()).

Test plan

  • node test/unit/connection/error-tests.js (new cases green)
  • Full packages/pg unit suite (find test/unit -name '*-tests.js' | xargs -n1 node) - 284 pass

Connection.sync() was setting _ending=true on every extended-query Sync.
That flag is meant for disconnect (Terminate / end()), so after the first
parameterized query ECONNRESET and EPIPE were swallowed for the life of
the connection. Keep _ending only on end() and connect-timeout teardown.

Fixes brianc#3769
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant