Skip to content

chore: bump mysql2 to 3.20 and pg to 8.20#894

Merged
JohnMcLear merged 1 commit intomainfrom
chore/modernize-mysql2-pg
Apr 7, 2026
Merged

chore: bump mysql2 to 3.20 and pg to 8.20#894
JohnMcLear merged 1 commit intomainfrom
chore/modernize-mysql2-pg

Conversation

@JohnMcLear
Copy link
Copy Markdown
Member

Summary

Driver modernization step 5. Both are minor version bumps:

  • mysql2 3.14 → 3.20 — tightens TypeScript overloads for pool.query(). The (options, callback) overload is no longer matched even though it still works at runtime. Cast to any for that one call site to preserve the existing runtime contract.
  • pg 8.16 → 8.20 — no driver-side type changes for our usage.

tsc --noEmit passes locally. test (mysql) will verify runtime in CI.

🤖 Generated with Claude Code

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Review Summary by Qodo

Modernize mysql2 and pg driver dependencies to latest minor versions

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Bump mysql2 from 3.14.5 to 3.20.0 with TypeScript overload fix
• Bump pg from 8.16.3 to 8.20.0 for driver modernization
• Cast pool.query() call to any to preserve runtime contract
• Update lock file with new dependency versions and transitive deps
Diagram
flowchart LR
  mysql2_old["mysql2 3.14.5"] -- "bump to" --> mysql2_new["mysql2 3.20.0"]
  pg_old["pg 8.16.3"] -- "bump to" --> pg_new["pg 8.20.0"]
  mysql2_new -- "tightened overloads" --> cast["Cast pool.query to any"]
  cast -- "preserves" --> runtime["Runtime contract"]
  pg_new -- "no type changes" --> compat["Compatible"]
Loading

Grey Divider

File Changes

1. databases/mysql_db.ts 🐞 Bug fix +6/-1

Cast pool.query to any for mysql2 3.20 compatibility

• Added explanatory comment about mysql2 3.20+ overload tightening
• Cast this._pool to any before calling query() method
• Preserves existing runtime behavior with (options, callback) signature

databases/mysql_db.ts


2. package.json Dependencies +2/-2

Bump mysql2 and pg to latest minor versions

• Updated mysql2 dependency from ^3.14.5 to ^3.20.0
• Updated pg dependency from ^8.16.3 to ^8.20.0

package.json


3. pnpm-lock.yaml Dependencies +76/-55

Update lock file with new driver and transitive dependency versions

• Updated mysql2 resolved version to 3.20.0 with @types/node peer dependency
• Updated pg resolved version to 8.20.0
• Updated transitive dependencies: iconv-lite, named-placeholders, lru.min, sql-escaper
• Updated pg ecosystem packages: pg-cloudflare, pg-connection-string, pg-pool, pg-protocol
• Removed obsolete dependencies: seq-queue, sqlstring, lru-cache@7.18.3
• Added libc specifiers to various rollup and resolver binding packages

pnpm-lock.yaml


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

qodo-free-for-open-source-projects bot commented Apr 7, 2026

Code Review by Qodo

🐞 Bugs (1)   📘 Rule violations (0)   📎 Requirement gaps (0)   🎨 UX Issues (0)
🐞\ ☼ Reliability (1)

Grey Divider


Remediation recommended

1. Promise never settles 🐞
Description
mysql_db._query() creates a Promise that is never resolved or rejected when this._pool is null
because the query call is guarded by this._pool && ... with no else path. Any call to _query()
before init() (or after teardown if _pool is cleared) will hang indefinitely.
Code

databases/mysql_db.ts[R46-55]

      return await new Promise((resolve, reject) => {
        options = {timeout: this.settings.queryTimeout, ...options};
-        this._pool && this._pool.query(options, (err:QueryError|null, ...args:string[]) => err != null ? reject(err) : resolve(args)
+        // mysql2 3.20+ tightened the query() overloads so the
+        // (options, callback) signature is no longer matched directly;
+        // pool.query(options, cb) still works at runtime but the types
+        // expect (sql, values, cb) or (sql, cb). Cast to any to call
+        // the runtime-correct (options, cb) form.
+        this._pool && (this._pool as any).query(options, (err:QueryError|null, ...args:string[]) => err != null ? reject(err) : resolve(args)
        );
      });
Evidence
_pool starts as null and is only assigned in init(). _query() wraps work in a Promise but only
triggers resolve/reject inside the callback passed to query(), which is never registered if
_pool is null, leaving the Promise pending forever.

databases/mysql_db.ts[24-40]
databases/mysql_db.ts[44-55]
databases/mysql_db.ts[62-72]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`databases/mysql_db.ts::_query()` returns a Promise that can remain pending forever if `this._pool` is null, because the `query()` call is short-circuited by `this._pool && ...` and there is no fallback that calls `resolve()`/`reject()`.

## Issue Context
`this._pool` is initialized to `null` in the constructor and set in `init()`. `_query()` is `async` and publicly accessible, so it can be called when the pool is not yet initialized.

## Fix Focus Areas
- databases/mysql_db.ts[44-55]
- databases/mysql_db.ts[24-40]
- databases/mysql_db.ts[62-72]

## Suggested change
Add an explicit guard at the start of `_query()` (before creating the Promise), e.g.:

- Capture `const pool = this._pool;`
- If `pool == null`, `throw new Error('MySQL pool not initialized')` (or `return Promise.reject(...)`).
- Use `pool.query(...)` (no short-circuit) so the Promise always settles.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@JohnMcLear JohnMcLear force-pushed the chore/modernize-mysql2-pg branch 3 times, most recently from 239d532 to 9f56fff Compare April 7, 2026 20:48
…20.0

Both are minor version bumps:
- mysql2 3.20 tightens TypeScript overloads for pool.query() so the
  (options, callback) form is no longer matched by the overload set,
  even though it still works at runtime. Cast to `any` for that one
  call so the existing runtime contract is preserved.
- pg 8.20 has no driver-side type changes for our usage.

tsc --noEmit passes. test (mysql) will verify runtime in CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JohnMcLear JohnMcLear force-pushed the chore/modernize-mysql2-pg branch from 9f56fff to b1ec5e4 Compare April 7, 2026 21:00
@JohnMcLear JohnMcLear merged commit 4199ce7 into main Apr 7, 2026
10 checks passed
@JohnMcLear JohnMcLear deleted the chore/modernize-mysql2-pg branch April 7, 2026 21:05
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.

1 participant