node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

conn.release() does not return a promise when using mysql2/promise library

Open shreya-work opened this issue 10 years ago • 1 comments

var mysql = require('mysql/promise');
var bluebird = require('bluebird);

const pool = mysql.createPool({
  connectionLimit: CONFIG.mysql.connectionLimit,
  host           : CONFIG.mysql.host,
  user           : CONFIG.mysql.user,
  password       : CONFIG.mysql.password,
  database       : CONFIG.mysql.database,
  Promise        : bluebird
});

const newActivityCount = co.wrap(function *(memberId) {
      var sql = "SELECT 1";
      var conn = yield pool.getConnection();
      var results = yield conn.execute(sql);
      yield conn.release();  <-- ERRORS OUT
      return results[0][0].newActivity;
  });

ERROR THROWN IS AS FOLLOWS:

You may only yield a function, promise, generator, array, or object, but the following object was passed: "undefined"

For details see here

shreya-work avatar Sep 28 '16 16:09 shreya-work

The .release() method doesn't take a callback, either. It's not an async method.

dougwilson avatar Sep 28 '16 17:09 dougwilson