Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin-mysql]: MaxListenersExceedWarning: Memory Leak #878

Closed
BowlingX opened this issue Mar 19, 2020 · 6 comments · Fixed by #880
Closed

[plugin-mysql]: MaxListenersExceedWarning: Memory Leak #878

BowlingX opened this issue Mar 19, 2020 · 6 comments · Fixed by #880
Assignees
Labels
bug Something isn't working

Comments

@BowlingX
Copy link

BowlingX commented Mar 19, 2020

What version of OpenTelemetry are you using?

0.5.0, plugin-mysql (also present in 0.4.0)

What version of Node are you using?

12.13.1

What did you do?

I'm using the plugin-mysql with a mysql pool.
After a short amount of requests with the plugin enabled, I get

(node:49932) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [Query]. Use emitter.setMaxListeners() to increase limit

Tracing the issue shows it comes from here:
https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-mysql/src/mysql.ts#L237

Without the plugin enabled, I don't have any issues.

@BowlingX BowlingX added the bug Something isn't working label Mar 19, 2020
@dyladan
Copy link
Member

dyladan commented Mar 19, 2020

looking into this

@dyladan
Copy link
Member

dyladan commented Mar 19, 2020

Can you give me more info like what ORM you are using if any and what your connection setup and query code looks like?

@BowlingX
Copy link
Author

BowlingX commented Mar 19, 2020

Thank you :).
No ORM. Basically just:

import mysql from 'mysql'

export const connection = mysql.createPool({
  connectionLimit: process.env.MYSQL_CONNECTION_LIMIT,
  host: process.env.MYSQL_HOST,
  port: process.env.MYSQL_PORT,
  user: process.env.MYSQL_USER,
  password: process.env.MYSQL_PASSWORD,
  database: process.env.MYSQL_DATABASE
})

export const query = async (query, preparedParams) => {
  return new Promise((resolve, reject) => {
    connection.query(query, preparedParams, (err, result) => {
      if (err) return reject(err)
      resolve(result)
    })
  })
}

@dyladan
Copy link
Member

dyladan commented Mar 19, 2020

@BowlingX I think I have a fix just need reviews and I'll get it pushed asap

@dyladan
Copy link
Member

dyladan commented Mar 20, 2020

Just published 0.5.1 which should fix your issue. Would appreciate if you could confirm for me.

@BowlingX
Copy link
Author

Works perfectly :) thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants