If returnArgumentsArray is set in the config to true, node crashes on pool.getConnection() with an error:
Unhandled rejection TypeError: Cannot read property 'apply' of undefined
at /path_to_project/node_modules/promise-mysql/lib/helper.js:26:45
at Promise._execute (/path_to_project/node_modules/bluebird/js/release/debuggability.js:384:9)
at Promise._resolveFromExecutor (/path_to_project/node_modules/bluebird/js/release/promise.js:518:18)
at new Promise (/path_to_project/node_modules/bluebird/js/release/promise.js:103:10)
at Array.promiseCallback (/path_to_project/node_modules/promise-mysql/lib/helper.js:8:16)
at poolConnection.rollback (/path_to_project/node_modules/promise-mysql/lib/connection.js:71:32)
at /path_to_project/helpers/mysql.js:43:24
My test app:
const config = require('./config.json');
const mysql = require('promise-mysql');
const createPool = mysql.createPool({
host: config.DB_HOST,
user: config.DB_USER,
password: config.DB_PASSWORD,
database: config.DB_NAME,
returnArgumentsArray: true, // if is set to true the pool.getConnection() does not work
});
function testTransaction() {
createPool.then(async (pool) => {
const connection = await pool.getConnection();
try {
await connection.beginTransaction();
const result = await connection.query('SELECT 1+1');
console.log(result);
await connection.commit();
await connection.release();
} catch (e) {
await connection.rollback();
await connection.release();
throw e;
}
});
}
testTransaction();
If
returnArgumentsArray
is set in the config to true, node crashes onpool.getConnection()
with an error:My test app: