Skip to content

sql: grow connection pool lazily instead of opening max on first use - #30636

Draft
robobun wants to merge 3 commits into
mainfrom
farm/b4c5677a/sql-lazy-pool
Draft

sql: grow connection pool lazily instead of opening max on first use#30636
robobun wants to merge 3 commits into
mainfrom
farm/b4c5677a/sql-lazy-pool

sql: grow connection pool lazily instead of opening max on first use

53a46a2
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jun 14, 2026 in 42m 55s

Code review found 2 potential issues

Found 3 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/js/internal/sql/shared.ts:1037-1043 Re-entrant #tryGrowPool() via synchronous password() can recurse unboundedly

Annotations

Check warning on line 1043 in src/js/internal/sql/shared.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

Re-entrant #tryGrowPool() via synchronous password() can recurse unboundedly

`#tryGrowPool()` checks `connections.length >= maxPoolSize` (line 1039) *before* `createPooledConnection()` returns and the slot is pushed (line 1041), but `createPooledConnection()` synchronously invokes a function-valued `password()` — so a `password()` that re-enters `sql.connect()` (the #32198 pattern) while another slot is already pending lands in the new `!all_closed` branch, calls `#tryGrowPool()` again with the same `connections.length`, and recurses unboundedly until `RangeError: Maximu