Files
bun.sh/test/regression
Claude Bot 653c7de613 fix(sql): resolve MySQL connection pool hang with pool size > 1
When a prepared statement completes, the code was calling queue.advance()
to process pending queries, but the data written to the buffer was not
being flushed. This caused a hang because:

1. The auto-flusher was registered in onData's defer block
2. But event_loop.exit() ran BEFORE registerAutoFlusher()
3. So the deferred task queue was drained before the auto-flusher was registered
4. The new data written by queue.advance() would never be flushed

The fix replaces queue.advance() with flushQueue() in several places:
- checkIfPreparedStatementIsDone() - main fix for the hang
- handleAuth() OK case - for consistency
- handleAuth() success auth case - for consistency
- handlePreparedStatement() ERROR case - for consistency

flushQueue() calls flushData() after queue.advance() to ensure any
data written by newly executed queries is actually sent to the server.

This is a follow-up to #26030, which fixed the same pattern for pool
size = 1. The issue persisted for pool size > 1 because the auto-flusher
timing is different when multiple connections are involved.

Fixes #26235

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 06:16:29 +00:00
..