sidorares / sidorares/node-mysql2

Valid Pool options (e.g. `acquireTimeout`) trigger "Ignoring invalid configuration option passed to Connection" warning

Open
#4,060 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation
Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

Bug Description

When using mysql2.createPoolCluster (or createPool) with valid pool-level options such as acquireTimeout, the library emits a warning indicating that the option is invalid for the Connection.

While acquireTimeout is a valid and necessary option for the Pool behavior, it seems the Pool implementation passes the entire configuration object down to the underlying Connection constructor without filtering out pool-specific keys. Since Connection now performs stricter validation (checking against a whitelist of known connection options), it flags acquireTimeout as invalid.

This creates a contradiction where a user provides a valid Pool configuration but receives warnings (which state they will become errors in future versions) because the underlying Connection doesn't recognize those Pool-specific settings.

Reproducible Example
const mysql = require('mysql2');

// Creating a pool cluster with valid pool options
const pool = mysql.createPoolCluster();

pool.add('MASTER', {
  host: 'localhost',
  user: 'root',
  database: 'test',
  // acquireTimeout is a valid Pool option (default 10000)
  // But passing it explicitly triggers the warning
  acquireTimeout: 10000 
});

pool.getConnection('MASTER', (err, connection) => {
  if (err) console.error(err);
  else {
    console.log('Connected!');
    connection.release();
  }
  pool.end();
});
Observed Behavior

The console outputs the following warning:

Ignoring invalid configuration option passed to Connection: acquireTimeout. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
Expected Behavior

Pool-specific options like acquireTimeout, connectionLimit, queueLimit, etc., should be consumed by the Pool and not passed down (or should be filtered out) when creating a new Connection instance. Alternatively, the Connection validator should allow/ignore known Pool options without emitting a warning.

Environment
  • Node.js Version: 20.x
  • MySQL2 Version: 3.10+
  • Operating System: macOS / Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the createPoolCluster/createPool flow and trace how pool configuration reaches the underlying Connection constructor. Reproduce the warning with acquireTimeout, then verify that pool options such as acquireTimeout, connectionLimit, and queueLimit remain functional without triggering the invalid-configuration warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, node.js, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.