Hello, i got a problem guys. I’m trying to connect to a database in JS using mysql2. Here’s my code
const mysql = require("mysql2");
require("./sv_config");
const pool = mysql.createPool(config.db.connectionInfo);
const promisePool = pool.promise();
on("mysql:query", async (sql, callback) => {
try {
const [rows, fields] = await promisePool.query(sql);
console.log(callback);
if (callback) callback(rows);
} catch (err) {
console.error(err);
}
});
But when i’m calling wuery like this
emit("mysql:query", "SELECT 1 + 1 AS solution", res => console.log(res));
I get this error
Error: BUFFER_SHORTAGE
at n.e [as reserve] (citizen:/scripting/v8/msgpack.js:29:12766)
at h (citizen:/scripting/v8/msgpack.js:29:15761)
at n.r [as decode] (citizen:/scripting/v8/msgpack.js:29:13908)
at n.fetch (citizen:/scripting/v8/msgpack.js:29:6972)
at n.u [as read] (citizen:/scripting/v8/msgpack.js:29:12076)
at Object.n [as decode] (citizen:/scripting/v8/msgpack.js:29:7097)
at unpack (citizen:/scripting/v8/main.js:20:33)
at citizen:/scripting/v8/main.js:51:11
at on (sv_mysql.js:11:19)
at <anonymous>
It only happens when doing : callback(result) in my query() function. I tried with exports and it’s basicaly the same
Anybody got an idea of where my problem might come from ?