Node-mysql2: this.connection.release is not a function

Created on 5 Feb 2017  Â·  3Comments  Â·  Source: sidorares/node-mysql2

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)

question

Most helpful comment

Oh, silly me – release is for connection pooling. I need .close().

All 3 comments

I must be overlooking something, but I don't see what – it looks like this.connection.release is undefined.

Oh, silly me – release is for connection pooling. I need .close().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hezjing picture hezjing  Â·  3Comments

HulioEglesias picture HulioEglesias  Â·  4Comments

sidorares picture sidorares  Â·  6Comments

picbenoit picture picbenoit  Â·  6Comments

vcorr picture vcorr  Â·  5Comments