Registry / database / mysql-connection-pool-manager

mysql-connection-pool-manager

JSON →
library1.5.9jsnpmunverified

A production-level Node.js wrapper for mysqljs/mysql that provides intelligent management and load balancing of MySQL connection pools. It automatically scales connections based on load, closes idle connections to prevent exhaustion of server max_connections, and supports instancing for custom clustering. Current stable version is 1.5.9, last updated in 2019. It requires mysql@>=2.14.0 <3.0.0 as a peer dependency and supports Node.js 8+. Key differentiators: automatic idle connection cleanup, dynamic configuration changes, and exported internal functions for custom scripts.

npm install mysql-connection-pool-manager
INSTALL
IMPORT
SIG · MYSQL-CONNECTION-P
M
mysql-connection-pool-manager
databasejavascriptv1.5.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import MySQLConnectionPoolManager from 'mysql-connection-pool-manager'
✗ const MySQLConnectionPoolManager = require('mysql-connection-pool-manager')
CommonJS require works for Node.js. ESM import may require bundler or Node.js >= 16 with { "type": "module" }.
MySQLConnectionPoolManager
✓ const { MySQLConnectionPoolManager } = require('mysql-connection-pool-manager')
✗ const PoolManager = require('mysql-connection-pool-manager').PoolManager
The package exports a single class named MySQLConnectionPoolManager. Named destructuring is valid but default import is more common.
getPool
✓ import MySQLConnectionPoolManager from 'mysql-connection-pool-manager'; const pool = manager.getPool()
✗ import { getPool } from 'mysql-connection-pool-manager'
getPool is an instance method, not a static or named export. Must call on an instance.

Demonstrates creating a MySQL connection pool manager, getting a connection, executing a query, and releasing the connection.

import MySQLConnectionPoolManager from 'mysql-connection-pool-manager'; const poolManager = new MySQLConnectionPoolManager({ poolConfig: { connectionLimit: 100, host: 'localhost', port: 3306, user: 'root', password: process.env.MYSQL_PASSWORD ?? '', database: 'test' }, poolManagerConfig: { maxWaitForConnection: 10000, maxKeepAlive: 30000, minKeepAlive: 10000, maxQueue: 50, trace: false } }); poolManager.getConnection((err, connection) => { if (err) throw err; connection.query('SELECT 1', (err, results) => { if (err) throw err; console.log(results); poolManager.releaseConnection(connection); }); });
Debug
Known issues
breakingVersion 1.0.0 changed the constructor signature; poolConfig and poolManagerConfig are now required objects.
fix
Update to pass poolConfig and poolManagerConfig as separate properties.
affects: <1.0.0
deprecatedThe method `getPool()` returns the internal mysql pool; direct access to the pool is discouraged in favor of using poolManager methods.
fix
Use `getConnection()` and `releaseConnection()` instead of manipulating the pool directly.
affects: >=1.0.0
gotchaThe peer dependency version `mysql@>=2.14.0 <3.0.0` is strictly enforced. Using mysql 3.x will cause runtime errors.
fix
Install mysql@2.x (e.g., npm install mysql@2.18.1).
affects: >=1.0.0
gotchaIf `maxQueue` is exceeded, new connection requests will be rejected immediately. Default is 50.
fix
Set a higher `maxQueue` value in poolManagerConfig if you expect many concurrent requests.
affects: >=1.0.0
deprecatedThe property `poolManagerConfig.trace` is deprecated and may be removed in future versions.
fix
Set `trace: false` to suppress deprecation warnings; remove in future.
affects: >=1.5.0
Errors
Common errors & fixes
Cannot find module 'mysql-connection-pool-manager'
Package not installed or typo in import/require path.
fix
Run `npm install mysql-connection-pool-manager` and ensure no typo in require/import.
Error: Can't set headers after they are sent.
Multiple responses sent in Express route handler, often due to calling next() after sending a response.
fix
Ensure each route handler sends only one response; avoid calling next() after res.send()/res.json()
TypeError: poolManager.getConnection is not a function
poolManager is not an instance of MySQLConnectionPoolManager; likely imported incorrectly.
fix
Use correct import: `const PoolManager = require('mysql-connection-pool-manager'); const poolManager = new PoolManager(...)`
Upgrade
Version history
1.5.9latest on npm
Audit
Dependencies
mysqlrequiredPeer dependency: the actual MySQL driver used internally for connection pooling and queries.
Agent activity
9 hits · last 30 days
node
8
Resources
mysql-connection-pool-manager — npm install mysql-connection-pool-manager · libregistry