Skip to content

fix: restore PoolConnection as subclass of Connection#4183

Merged
wellwelwel merged 8 commits intosidorares:masterfrom
wellwelwel:pool
Mar 15, 2026
Merged

fix: restore PoolConnection as subclass of Connection#4183
wellwelwel merged 8 commits intosidorares:masterfrom
wellwelwel:pool

Conversation

@wellwelwel
Copy link
Collaborator

@wellwelwel wellwelwel commented Mar 14, 2026

This PR restores PoolConnection as a proper subclass of Connection, fixing the instanceof check that broke in 3.11.5 after the circular dependency refactor (#3081).

Closes #3273.


Before #3081, the inheritance chain was:

  • PoolConnectionConnection

After #3081 resolved circular dependencies, it became:

  • PoolConnectionBasePoolConnectionBaseConnection

This caused PoolConnection.prototype instanceof Connection to return false, an unintentional breaking change released as a patch.


Now, PoolConnection extends Connection directly, inlining the pool-specific logic that was in BasePoolConnection (constructor, release, end, destroy, _removeFromPool):

  • PoolConnectionConnectionBaseConnection

Note

  • To ensure that circular imports do not occur again, this is now tested using Rollup.
  • With no remaining consumers, lib/base/pool_connection.js is removed

The typing previously had redundant interfaces that shadowed class exports from export *:

// before
export interface Connection extends BaseConnection {}
export interface PoolConnection extends BasePoolConnection {}

These interfaces were structurally identical to their respective classes and only served to hide the class value from the export. Removing them and adding export * from './lib/PoolConnection.js' makes both Connection and PoolConnection available as constructors (now it's additive, not breaking).

Important

An alternative approach was explored in #3321, which instead changed the types to match the broken runtime (PoolConnection extends BaseConnection). That would force a breaking change for everyone depending on the Connection type.

This PR takes the opposite direction: fix the runtime so types remain correct.

@wellwelwel wellwelwel changed the title Pool fix: restore PoolConnection as subclass of Connection Mar 14, 2026
@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.69%. Comparing base (90a0677) to head (3f77ed0).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4183      +/-   ##
==========================================
+ Coverage   90.58%   90.69%   +0.10%     
==========================================
  Files          87       86       -1     
  Lines       14281    14266      -15     
  Branches     1798     1802       +4     
==========================================
+ Hits        12937    12939       +2     
+ Misses       1344     1327      -17     
Flag Coverage Δ
compression-0 89.95% <100.00%> (+0.10%) ⬆️
compression-1 90.67% <100.00%> (+0.10%) ⬆️
static-parser-0 88.38% <100.00%> (+0.10%) ⬆️
static-parser-1 89.11% <100.00%> (+0.10%) ⬆️
tls-0 90.13% <100.00%> (+0.10%) ⬆️
tls-1 90.48% <100.00%> (+0.10%) ⬆️

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 wellwelwel marked this pull request as ready for review March 15, 2026 00:12
@wellwelwel
Copy link
Collaborator Author

wellwelwel commented Mar 15, 2026

Before (errors in both the JavaScript core and the types):

Screenshot 2026-03-14 at 21 11 47

Now:

Screenshot 2026-03-14 at 21 12 16

@wellwelwel
Copy link
Collaborator Author

wellwelwel commented Mar 15, 2026

And now, the same for promise-based imports 🎉

Before (errors in both the JavaScript core and the types):

Screenshot 2026-03-14 at 21 18 34

Now:

Screenshot 2026-03-14 at 21 24 10

@wellwelwel wellwelwel merged commit 97855a6 into sidorares:master Mar 15, 2026
88 checks passed
@wellwelwel wellwelwel deleted the pool branch March 15, 2026 01:30
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.

Breaking Change: PoolConnection is no longer derived from Connection since 3.11.5.

1 participant