-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: close connections that exceeds opts.idleTimeout #159
Conversation
6c14bd4
to
48476a1
Compare
48476a1
to
6309822
Compare
return connection; | ||
} | ||
await new Promise(resolve => queue.push(resolve)); | ||
return await this.getConnection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may cause infinite loop in some edge case. How about set a waiting timeout, then throw error while waiting timeout and no connection available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default behavior that the mysql client supports, when connection pool is drained, wait for connection being released.
this.emit('release', connection); | ||
|
||
const { queue } = this; | ||
while (queue.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the queue use for what? It seems store resolve
functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a simple hack for referencing hanging awaits in getConnection
, when new connection is available, begin dequeue continue previous blocking jobs.
fixes #148, closes #60 with a mocked Pool and Connection for sqlite driver