Skip to content

Conversation

@AxiosLeo
Copy link
Owner

@AxiosLeo AxiosLeo commented Dec 19, 2025

Note

Adds pool-aware transaction API (beginTransaction/commit/rollback) with updated typings and docs, plus Docker-based MySQL feature tests and expanded CI node matrix.

  • Core (transactions):
    • Add QueryHandler.beginTransaction(options) that acquires/reuses connections (pool-aware) and auto-releases on commit/rollback.
    • Add QueryHandler.commit() and QueryHandler.rollback() helpers.
  • Types:
    • Update index.d.ts with beginTransaction, commit, rollback, and TransactionLevel typings.
  • Docs & Examples:
    • Expand README with transaction usage (pool, direct handler, row locking, concurrency, best practices).
    • Add examples/transaction_example.js showcasing recommended patterns.
  • Tests & CI:
    • Add Docker Compose MySQL (docker-compose.yml) and feature test setup: tests/init-feature-tables.sql, tests/setup-feature-db.js, tests/transaction.ft.js.
    • New GitHub Actions workflow feature-test.yml to run containerized MySQL feature tests.
    • Expand CI matrix in .github/workflows/ci.yml to Node 22, 24 and keep macOS/Ubuntu.
    • Add npm scripts: feature-test, setup-feature-db, feature-test:local.

Written by Cursor Bugbot for commit 4d59577. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

resolve(connection);
}
});
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Promise pool getConnection causes application to hang indefinitely

The comment on line 290 claims this code "works for both callback and promise pools" but it only works with callback-style pools. When using a promise pool from mysql2/promise, the getConnection method returns a Promise and ignores the callback argument. This causes the outer new Promise to never resolve, hanging the application indefinitely. The example file examples/transaction_example.js demonstrates this exact broken pattern by importing from mysql2/promise and creating a pool, which would cause beginTransaction to hang when called.

Additional Locations (1)

Fix in Cursor Fix in Web

}

await transaction.begin();
return transaction;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Connection leak when transaction.begin() fails

If transaction.begin() throws an error on line 342, the pool connection obtained earlier (lines 291-304) is never released back to the pool. The connection release logic is only in the overridden commit() and rollback() methods, which are never called when begin() fails. This causes connection pool exhaustion over time as failed begin attempts leak connections.

Fix in Cursor Fix in Web

@AxiosLeo AxiosLeo merged commit 334a392 into main Dec 19, 2025
13 checks passed
@AxiosLeo AxiosLeo deleted the feat/transaction branch December 19, 2025 07:45
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.

2 participants