ReviewOS

stacks/bun-query-builder

Connection cache ignores host/port/url/pool changes after setConfig (no resetConnection)

#1041
Closed glennmichael123 opened this 22 days ago · 0 comments
22 days ago

Summary

getOrCreateBunSql only rebuilds when dialect or database.database changes. Changing host, port, username, password, url, or pool via setConfig does not invalidate the cached connection, and setConfig never calls resetConnection. Callers must know to call resetConnection() manually — undocumented at the setConfig boundary.

Location

src/db.ts:~469-483; setConfig in src/config.ts:~160.

Suggested fix

Key the cache on the full resolved connection string + pool options, or have setConfig call resetConnection() when any database.* field changes.

Severity: medium. Found via internal code audit.

Sign in to comment on this issue.