0

For some reason, my node app (specifically the node module) is getting a "Too many connections" error that I can't figure out what is actually causing it, but rather than handling the error it's completely crashing the app.

To give you an idea of what this looks like:

/node_modules/mysql/lib/protocol/sequences/Sequence.js:52
  var err  = new Error(code + ': ' + packet.message);
             ^
Error: ER_CON_COUNT_ERROR: Too many connections

What is the best way to handle this so it is not actually killing the app?

This is when running npm run dev.

Thingamajig
  • 4,107
  • 7
  • 33
  • 61
  • 1
    Hard to tell... you need to give more code... – Flash Thunder May 18 '18 at 19:33
  • 1
    The error is pain fully obvious what your doing. Your not closing or reusing the database connections and are opening new ones every time. – Darkrum May 18 '18 at 19:55
  • `but rather than handling the error it's completely crashing the app.` It's crashing the app because **you** are not handling the error. I recommend using a connection pool. – Marcos Casagrande May 18 '18 at 20:16
  • Somewhere in your code you are not closing your connections and or not using a connection pool. Possible duplicate: https://stackoverflow.com/questions/27746512/er-con-count-error-too-many-connections-error-in-node-mysql?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Dennis May 18 '18 at 20:51
  • Possible duplicate of [ER\_CON\_COUNT\_ERROR: Too many connections error in node-mysql](https://stackoverflow.com/questions/27746512/er-con-count-error-too-many-connections-error-in-node-mysql) – Dennis May 18 '18 at 20:51

1 Answers1

-1

I solved an issue related to this using

try{

}
catch (e){

}
cigien
  • 57,834
  • 11
  • 73
  • 112
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 04 '22 at 04:58