Skip to content

Commit

Permalink
fix: fix mysql2 invalid configuration option poolWaitTimeout (#8)
Browse files Browse the repository at this point in the history
Unpicked `options` will become `mysqlOptions` and pass to mysql2, mean
while mysql2 will console.error a message, causing egg fail to start.


![image](https://github.com/user-attachments/assets/19bb92fa-1c98-4e7b-8195-5cf7ff303e1d)

![image](https://github.com/user-attachments/assets/88108c2b-ef9e-4c34-b74b-93cb609101b3)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced configurability of the RDSClient by adding a
`poolWaitTimeout` option for improved connection management.


<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
ShadyZOZ authored Sep 6, 2024
1 parent b359064 commit 7293c2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class RDSClient extends Operator {
constructor(options: RDSClientOptions) {
super();
options.connectTimeout = options.connectTimeout ?? 500;
const { connectionStorage, connectionStorageKey, ...mysqlOptions } = options;
const { connectionStorage, connectionStorageKey, poolWaitTimeout, ...mysqlOptions } = options;
// get connection options from getConnectionConfig method every time
if (mysqlOptions.getConnectionConfig) {
this.#pool = new Pool({ config: new RDSPoolConfig(mysqlOptions, mysqlOptions.getConnectionConfig) } as any) as unknown as PoolPromisify;
Expand All @@ -83,7 +83,7 @@ export class RDSClient extends Operator {
});
this.#connectionStorage = connectionStorage || new AsyncLocalStorage();
this.#connectionStorageKey = connectionStorageKey || RDSClient.#DEFAULT_STORAGE_KEY;
this.#poolWaitTimeout = options.poolWaitTimeout ?? 500;
this.#poolWaitTimeout = poolWaitTimeout ?? 500;
// https://github.com/mysqljs/mysql#pool-events
this.#pool.on('connection', (connection: PoolConnectionPromisify) => {
channels.connectionNew.publish({
Expand Down

0 comments on commit 7293c2e

Please sign in to comment.