Mysql: promisify( pool.getConnection ) throws unexpected error

Created on 22 Mar 2018  路  2Comments  路  Source: mysqljs/mysql

pool = require('mysql').createPool(
{
  connectionLimit : 5,
  host,
  user,
  password
}),
getConnection = promisify(pool.getConnection),
connection    = await getConnection(),
TypeError: Cannot read property 'length' of undefined
    at Pool.getConnection (/opt/provision/node_modules/mysql/lib/Pool.js:36:29)
    at internal/util.js:238:30
    at module.exports.createTransaction (/opt/provision/model/db/gateway/mysql.js:33:33)
    at Noc.createTransaction (/opt/provision/model/db/repository/noc.js:11:32)
    at module.exports (/opt/provision/model/activate-order.js:14:35)
    at module.exports.activate (/opt/provision/controller/activate-order.js:24:13)
    at module.exports.post (/opt/provision/controller/activate-order.js:15:23)
    at module.exports.dispatch (/opt/provision/node_modules/@superhero/core/controller/dispatcher/rest.js:23:42)
    at module.exports.dispatch (/opt/provision/node_modules/@superhero/core/controller/server/http.js:53:49)
    at <anonymous>

Most helpful comment

Hi, I have the exact same issue, care to elaborate how you resolve it? Thanks!


Edit:
Just resolved the problem.

const getConnection = util.promisify(pool.getConnection.bind(pool));

All 2 comments

Forgot to bind the instance....

Hi, I have the exact same issue, care to elaborate how you resolve it? Thanks!


Edit:
Just resolved the problem.

const getConnection = util.promisify(pool.getConnection.bind(pool));

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ajpyoung picture ajpyoung  路  4Comments

wahengchang picture wahengchang  路  3Comments

Axxxx0n picture Axxxx0n  路  3Comments

flowl picture flowl  路  4Comments

johnrc picture johnrc  路  3Comments