Minimal standalone repro for Bun MySQL connection instability in a cache-like workload.
Set environment variables:
MYSQL_HOSTMYSQL_USERMYSQL_PASSWORDMYSQL_DATABASE- optional:
MYSQL_PORT - optional:
MYSQL_TLS(trueorfalse, defaultfalse)
Default scenario (single connection for reads+writes, transactional write):
REPRO_MODE=single REPRO_TX=true REPRO_ROWS=30000 REPRO_BATCH=500 bun scripts/bun-mysql-repro/repro.tsSplit read/write connections:
REPRO_MODE=split REPRO_TX=true REPRO_ROWS=30000 REPRO_BATCH=500 bun scripts/bun-mysql-repro/repro.tsAutocommit write (no transaction):
REPRO_MODE=single REPRO_TX=false REPRO_ROWS=30000 REPRO_BATCH=100 bun scripts/bun-mysql-repro/repro.ts- Creates two repro tables:
bun_repro_cached_rangesbun_repro_cached_inventory_movements
- Clears scenario-specific rows
- Reads range metadata
- Writes a large batch of movement rows
- Reads rows back
If the runtime fails, output typically stops mid-step (or reports MySQLError: Connection closed).
- This script is intentionally independent of app code.
- It uses only
Bun.SQLand MySQL.