The following is producing an error:
import mysql from 'mysql2/promise';
const createConnection = () => {
return mysql.createConnection({
database: databaseDatabase,
host: databaseHost,
password: databasePassword,
user: databaseUser
});
};
const audit = async () => {
const connection = await createConnection();
connection.release();
};
audit();
TypeError: this.connection.release is not a function
at PromiseConnection.release (/Users/gajus/Documents/dev/applaudience/showtime-data-sources-auditor/node_modules/mysql2/promise.js:25:19)
at /Users/gajus/Documents/dev/applaudience/showtime-data-sources-auditor/src/bin/server.js:69:14
at Generator.next (<anonymous>)
at step (/Users/gajus/Documents/dev/applaudience/showtime-data-sources-auditor/src/bin/server.js:17:191)
at /Users/gajus/Documents/dev/applaudience/showtime-data-sources-auditor/src/bin/server.js:17:361
at process._tickDomainCallback (internal/process/next_tick.js:129:7)
I must be overlooking something, but I don't see what – it looks like this.connection.release is undefined.
There is no release method on Connection constructor.
Oh, silly me – release is for connection pooling. I need .close().
Most helpful comment
Oh, silly me – release is for connection pooling. I need
.close().