knaadh / nestjs-drizzle

A NestJS module for integrating DrizzleORM with Postgres, MySQL, SQLite, Turso and Planetscale drivers
MIT License
133 stars 8 forks source link

Connection won't restart itself when it crash unreached from network. #18

Closed vireakvibol closed 2 weeks ago

vireakvibol commented 1 month ago

On connection pooling i saw it try to retried to connect until it's too long or it's reach timeout and it won retry and keep the application error forever to connect to database until a manual intervention is made to restart the application itself.

How eliminate that timeout or retry limit or something similar to keep it retry forever when have unexpected disconnect like network error or database service down? Application Version
NestJS 10.4.3
Drizzle Client 0.31.4
knaadh/nestjs-drizzle-mysql2 1.0.1
MySQL 8
[Nest] 1  - 09/30/2024, 2:50:43 AM   ERROR [ExceptionsHandler] read ECONNRESET

Error: read ECONNRESET

at PromisePool.query (/app/node_modules/.pnpm/mysql2@3.11.3/node_modules/mysql2/promise.js:356:22)

at MySql2PreparedQuery.execute (/app/node_modules/.pnpm/drizzle-orm@0.31.4_mysql2@3.11.3/node_modules/drizzle-orm/mysql2/session.cjs:71:33)

at QueryPromise.execute (/app/node_modules/.pnpm/drizzle-orm@0.31.4_mysql2@3.11.3/node_modules/drizzle-orm/mysql-core/query-builders/query.cjs:131:27)

at QueryPromise.then (/app/node_modules/.pnpm/drizzle-orm@0.31.4_mysql2@3.11.3/node_modules/drizzle-orm/query-promise.cjs:44:17)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
mithleshjs commented 1 month ago

You need to consult the docs of mysql2 to achieve that. Another way is to manually handle the connection errors.