Skip to content

Fix COPY TO query timeout cleanup - #175

Open
zfaustk wants to merge 2 commits into
brianc:masterfrom
zfaustk:fix/copy-to-query-timeout
Open

Fix COPY TO query timeout cleanup#175
zfaustk wants to merge 2 commits into
brianc:masterfrom
zfaustk:fix/copy-to-query-timeout

Conversation

@zfaustk

@zfaustk zfaustk commented Aug 12, 2026

Copy link
Copy Markdown

Fixes #156.

pg only installs its query_timeout cleanup callback on Submittables that expose a callback. COPY FROM already follows that contract, but COPY TO did not, so its timer could remain active after either an error or a successful ReadyForQuery.

This mirrors the existing COPY FROM integration by exposing the callback hook and invoking it from both terminal paths. The regression tests exercise error and success cleanup directly without requiring a running PostgreSQL server.

Validation:

  • npx mocha --v8-expose-gc test/obuf.js — 28 passing
  • npm run lint — passed
  • git diff --check — passed
  • Full npm test was attempted, but the local PostgreSQL prerequisite was unavailable; both the untouched base and this branch fail in the global setup with the same ECONNREFUSED.

AI assistance: Codex was used to inspect the code, implement the change, and run the tests. The final diff and claims are backed by the recorded RED-to-GREEN test output.

## Context
- Principle: COPY TO terminal paths must notify pg.Client so query timeouts are cleared exactly once.
- Why: Real client integration coverage proves timeout cleanup at the user-visible lifecycle boundary.

## Key Deltas
- COPY TO integration coverage: direct handler callback stubs -> real pg.Client error and success timeout assertions; why: exercise the timeout lifecycle through the owning client. Key refs: test/copy-to.js:21, test/copy-to.js:108, test/obuf.js:1

## Verification
- Result: passed
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.

COPY TO with query_timeout

1 participant