From acea9f952b0f9d66d14e97a5d417d02124ce88df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B6=E5=BC=8C?= Date: Thu, 23 Oct 2025 20:03:59 +0800 Subject: [PATCH 1/3] fix: add catch for get conn exception --- src/client.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client.ts b/src/client.ts index a663db6..53dd55e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -167,6 +167,8 @@ export class RDSClient extends Operator { if (typeof connOrTimeout === 'number') { connPromise.then(conn => { conn.release(); + }).catch(() => { + // ... do nothing, make sure has no unhandledRejectionError }); throw new PoolWaitTimeoutError(`get connection timeout after ${connOrTimeout}ms`); } From 93e75cbe516bd54547e5bebcfa306a0a22cc09b8 Mon Sep 17 00:00:00 2001 From: killagu Date: Thu, 23 Oct 2025 20:08:18 +0800 Subject: [PATCH 2/3] fix: add catch for get conn exception --- package.json | 3 ++- src/client.ts | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8865a0a..6100faf 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ }, "dependencies": { "mysql2": "^3.9.1", - "sqlstring": "^2.3.3" + "sqlstring": "^2.3.3", + "onelogger": "^1.0.0" }, "devDependencies": { "@eggjs/tsconfig": "^1.3.2", diff --git a/src/client.ts b/src/client.ts index 53dd55e..28ab02b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -3,6 +3,7 @@ import { promisify } from 'node:util'; import { setTimeout } from 'node:timers/promises'; import mysql, { Pool } from 'mysql2'; import type { PoolOptions } from 'mysql2'; +import { getLogger } from 'onelogger'; import type { PoolConnectionPromisify, RDSClientOptions, TransactionContext, TransactionScope } from './types'; import { Operator } from './operator'; import { RDSConnection } from './connection'; @@ -167,7 +168,10 @@ export class RDSClient extends Operator { if (typeof connOrTimeout === 'number') { connPromise.then(conn => { conn.release(); - }).catch(() => { + }).catch(e => { + const logger = getLogger(); + e.message = 'get conn failed after timeout: ' + e.message; + logger.warn(e); // ... do nothing, make sure has no unhandledRejectionError }); throw new PoolWaitTimeoutError(`get connection timeout after ${connOrTimeout}ms`); From c17dbe0320794de47df52e1707002f946e118639 Mon Sep 17 00:00:00 2001 From: killagu Date: Thu, 23 Oct 2025 20:12:55 +0800 Subject: [PATCH 3/3] f --- src/client.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 28ab02b..3ab1b1a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -172,7 +172,6 @@ export class RDSClient extends Operator { const logger = getLogger(); e.message = 'get conn failed after timeout: ' + e.message; logger.warn(e); - // ... do nothing, make sure has no unhandledRejectionError }); throw new PoolWaitTimeoutError(`get connection timeout after ${connOrTimeout}ms`); }