Drizzle + Astro => ETIMEDOUT

I have been running Astro with Drizzle for a period of time now, in one project. The project used to use Prisma, but i wanted to try out Drizzle When i develop on the project, i run the astro with npm run dev. I connect to Drizzle with this piece of code:
import { drizzle } from 'drizzle-orm/mysql2';
import mysql from 'mysql2/promise';
const poolConnection:mysql.Pool = mysql.createPool(
{
host: import.meta.env.DATABASE_HOST,
user: import.meta.env.DATABASE_USER,
password: import.meta.env.DATABASE_PASS,
database: import.meta.env.DATABASE_NAME,
});
export const db = drizzle(poolConnection);
import { drizzle } from 'drizzle-orm/mysql2';
import mysql from 'mysql2/promise';
const poolConnection:mysql.Pool = mysql.createPool(
{
host: import.meta.env.DATABASE_HOST,
user: import.meta.env.DATABASE_USER,
password: import.meta.env.DATABASE_PASS,
database: import.meta.env.DATABASE_NAME,
});
export const db = drizzle(poolConnection);
It works perfectly, HOWEVER, after a while of inactivity - when i do not reload the page often enough - then I will (once i reload) get a ETIMEDOUT and npm run dev simply just breaks the current process, and quitting npm altogether. If i convert back to Prisma - I do not get this behavour. If i try to use "non-pool" version of Drizzle, then it appears that drizzle does not close connections to my MySQL, and i hit the "max 10 connections" limit of my database. Any advise would be greatly appreciated.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server