using disposes the resource when the block ends
Files, locks, database clients and timers all need a matching release, and try/finally for each one is noise that people forget. using calls Symbol.dispose at the end of the scope.
{
using client = await pool.connect(); // client[Symbol.asyncDispose] releases it
await client.query("...");
}TypeScript 5.2 plus, with await using for async cleanup. Wrap third-party handles in a small object that implements the symbol and the leaks stop.
typescript