Skip to content

fix: reject operations on closed transaction handles - #1062

Merged
tdrz merged 1 commit into
electric-sql:mainfrom
psh4607:fix/1049-closed-transaction-handle
Jul 28, 2026
Merged

fix: reject operations on closed transaction handles#1062
tdrz merged 1 commit into
electric-sql:mainfrom
psh4607:fix/1049-closed-transaction-handle

Conversation

@psh4607

@psh4607 psh4607 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Background

Retained transaction handles can currently execute queries after their transaction has ended. tx.sql skips the closed-handle guard, and the automatic rollback path for a rejected callback leaves the handle marked open. Subsequent operations then run against the live auto-commit connection, allowing writes that callers expect to have been rolled back to persist.

Related issue

Fixes #1049

Changes

  • Call checkClosed() before executing tx.sql.
  • Mark the transaction handle closed before rolling back a rejected callback.
  • Add ESM and CJS regression coverage for commit, explicit rollback, and callback rejection.
  • Add a patch changeset for @electric-sql/pglite.

Tests

  • pnpm --dir packages/pglite build
  • pnpm --dir packages/pglite typecheck
  • pnpm --dir packages/pglite stylecheck
  • pnpm --dir packages/pglite test (283 passed, 1 skipped)

@psh4607
psh4607 marked this pull request as ready for review July 20, 2026 07:44
@tdrz
tdrz self-requested a review July 28, 2026 08:09
@tdrz
tdrz merged commit 7e784a4 into electric-sql:main Jul 28, 2026
14 checks 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.

tx.sql on an ended transaction handle silently writes to the auto-commit connection

2 participants