question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v1.6.2 throws on getConnection when using createPoolCluster

See original GitHub issue

When creating a cluster using mysql.createPoolCluster() the call to cluster.getConnection() throws in 1.6.2. This worked fine in previous versions of mysql2.

Run the following code to reproduce the bug:

const mysql = require('mysql2')

const cluster = mysql.createPoolCluster()

cluster.add({ host: 'localhost', user: 'root', database: 'test' })

// This call throws
cluster.getConnection(function (err, conn) {
  if (err) throw err
  console.log('success!')
})

This code will throw the following error:

/tmp/node_modules/mysql2/lib/pool_cluster.js:36
    this._selector = new Selector[selector]();
                     ^

TypeError: Selector[selector] is not a constructor
    at new PoolNamespace (/tmp/node_modules/mysql2/lib/pool_cluster.js:36:22)
    at PoolCluster.of (/tmp/node_modules/mysql2/lib/pool_cluster.js:96:31)
    at PoolCluster.getConnection (/tmp/node_modules/mysql2/lib/pool_cluster.js:121:24)
    at Object.<anonymous> (/tmp/test.js:8:9)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
SimonSchickcommented, Nov 6, 2018

That said, I apologize for causing this regression, I’d never seen that one coming 😛

0reactions
watsoncommented, Nov 6, 2018

@sidorares works now, thanks 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the mysql.createPoolCluster function in mysql - Snyk
To help you get started, we've selected a few mysql.createPoolCluster examples, based on popular ways it is used in public projects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found