node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

Promise Pool: Inconsistent types, missing releaseConnection function

Open perry-mitchell opened this issue 3 years ago • 4 comments

Hi,

I'm looking at implementing a connection pool, using the promise entry, but as I can see here there isn't a releaseConnection function.

Additionally, when looking at the standard connection pool types, the releaseConnection method is not typed at all.

perry-mitchell avatar Apr 20 '22 17:04 perry-mitchell

there is a PromiseConnection.release - https://github.com/sidorares/node-mysql2/blob/131c6b852127bc3af33f542f60231bf19cf99509/promise.js#L87-L89 which is typed here https://github.com/sidorares/node-mysql2/blob/dbb344e89a1cc8bb457b24e67b07cdb3013fe844/promise.d.ts#L85

sidorares avatar Apr 21 '22 02:04 sidorares

You're right, it is. Couldn't find it in the documentation.

What about the types for releaseConnection on the standard pool?

perry-mitchell avatar Apr 21 '22 04:04 perry-mitchell

You're right, it is. Couldn't find it in the documentation.

I think the promise wrapper is increasingly becoming the most popular api and deserve place at the beginning of readme, while callback style api can reuse documentation from mysqljs/mysql

What about the types for releaseConnection on the standard pool?

looks like it's outdated, now deprecated PoolConnection.end() used to be a way to release connection back into the pool

sidorares avatar Apr 21 '22 04:04 sidorares

@perry-mitchell would you like to contribute a fix to missing typings? If you can think of some test harness that would be awesome ( have a unit test in TS that can both run without runtime errors and pass static type checks )

sidorares avatar Apr 22 '22 01:04 sidorares

I'll close this one as we also discuss same issue in #1761

sidorares avatar Jun 10 '23 05:06 sidorares