Skip to content

Conversation

@CodeVoyager-bit
Copy link

This PR fixes an issue where calling end() on a PoolConnection would not execute the provided callback or resolve the promise when using the Promise API.

Previously, PoolConnection.end() did not accept any arguments, causing the callback to be ignored and the Promise wrapper to hang indefinitely.

Changes

  • Updated PoolConnection.prototype.end to accept a callback parameter.
  • Ensure callback is executed after releasing the connection back to the pool (when gracefulEnd is false).
  • Pass callback to super.end() when gracefulEnd is true.

Related Issue

Fixes #3915

@codecov
Copy link

codecov bot commented Nov 30, 2025

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.77%. Comparing base (9e8f539) to head (498574b).

Files with missing lines Patch % Lines
lib/base/pool_connection.js 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3937      +/-   ##
==========================================
- Coverage   89.78%   89.77%   -0.02%     
==========================================
  Files          86       86              
  Lines       13607    13610       +3     
  Branches     1607     1608       +1     
==========================================
+ Hits        12217    12218       +1     
- Misses       1390     1392       +2     
Flag Coverage Δ
compression-0 88.88% <60.00%> (-0.02%) ⬇️
compression-1 89.75% <60.00%> (-0.02%) ⬇️
static-parser-0 87.34% <60.00%> (-0.02%) ⬇️
static-parser-1 88.11% <60.00%> (-0.02%) ⬇️
tls-0 89.17% <60.00%> (-0.02%) ⬇️
tls-1 89.54% <60.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wellwelwel
Copy link
Collaborator

Thanks, @CodeVoyager-bit! Can you add a variation with this fix in the test test/integration/graceful-end/test-end-with-graceful-end-config.test.cjs?

About the lint error, you can run the command npm run lint:fix to fix it 🙋🏻‍♂️

Updated deprecation warning message for conn.end() usage.
@wellwelwel wellwelwel changed the title Fix PoolConnection.end() callback and promise resolution fix: Fix PoolConnection.end() callback and promise resolution Nov 30, 2025
@CodeVoyager-bit
Copy link
Author

@wellwelwel can you please review it once

Comment on lines +49 to +51
if (callback) {
callback();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is not being reached by the tests, I'm thinking of some approach to ensure continuity of this fix in the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling end on a pool connection never resolves / triggers cb

2 participants