-
-
Notifications
You must be signed in to change notification settings - Fork 653
Description
When calling end() on a pool connection, the function does not execute the provided callback. In the promise API, the promise does not resolve.
The type definitions indicate that it this should be the expected behaviour:
- Callback API
node-mysql2/typings/mysql/lib/Connection.d.ts
Line 384 in d950b98
end(callback?: (err: QueryError | null) => void): void; - Promise API
Line 63 in d950b98
end(options?: any): Promise<void>;
The implementation of end() for the pool connection does not have any parameters so cannot execute any provided callback. The promise API doesn't call resolve() on the wrapping Promise:
- Pool connection end
node-mysql2/lib/base/pool_connection.js
Line 32 in d950b98
end() { - Pool connection end promise wrapper
node-mysql2/lib/promise/connection.js
Lines 63 to 67 in d950b98
end() { return new this.Promise((resolve) => { this.connection.end(resolve); }); }
The fix for this should be to align the implementation with the type definitions - support providing a callback and resolving the promise for pool connections. I'd be happy to submit a PR for this if this feels like the right approach.