Martin Lefebvre's blog

Javascript

The Singleton

Handling MySQL Connections in TypeScript: The Good, the Bad, and the “Too Many Connections” Error When building a TypeScript application that talks to MySQL, how you manage database connections matters more than it might initially appear. A seemingly harmless pattern can quietly work its way into production and, under load, bring your application down with the dreaded: Error: Too many connections In this post, we will look at a bad but common approach to handling MySQL connections, why it causes problems, and then contrast it with a simple, effective approach that leverages ES modules and the Singleton pattern—without classes.