Skip to content

fix(promise): forward pool error events - #4487

Closed
GiHoon1123 wants to merge 4 commits into
sidorares:masterfrom
GiHoon1123:fix/pool-error-event-types
Closed

GiHoon1123 wants to merge 4 commits into
sidorares:masterfrom
GiHoon1123:fix/pool-error-event-types

Conversation

@GiHoon1123

Copy link
Copy Markdown

Refs #3749

Promise pools inherit lifecycle events from the underlying core pool, but the error event was not forwarded and was not exposed in the promise pool types.

This adds error to the forwarded pool events and adds a matching pool.on('error', ...) overload for the promise API. The existing promise wrapper event test now covers error forwarding, and the TypeScript build tests cover the promise pool event signature.

Tests:

  • npm run typecheck
  • npm run lint
  • npm run test:build

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.51%. Comparing base (f3a60bc) to head (90f419a).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4487   +/-   ##
=======================================
  Coverage   92.50%   92.51%           
=======================================
  Files          93       93           
  Lines       15909    15915    +6     
  Branches     2275     2275           
=======================================
+ Hits        14717    14723    +6     
  Misses       1192     1192           
Flag Coverage Δ
compression-0 92.12% <100.00%> (+<0.01%) ⬆️
compression-1 92.49% <100.00%> (+<0.01%) ⬆️
static-parser-0 91.32% <100.00%> (+<0.01%) ⬆️
static-parser-1 91.44% <100.00%> (+<0.01%) ⬆️
tls-0 92.07% <100.00%> (+<0.01%) ⬆️
tls-1 92.51% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@sidorares

Copy link
Copy Markdown
Owner

@wellwelwel don't merge just yet. Wanted to check first that pool tracks idle connection errors at all - that might be not the case

@wellwelwel wellwelwel linked an issue Aug 24, 2026 that may be closed by this pull request
@GiHoon1123

Copy link
Copy Markdown
Author

Traced it — you're right to hold off.

PoolConnection's constructor swallows connection errors itself:

this.once('error', () => {
  this._removeFromPool();
});

_removeFromPool()pool._removeConnection(this), which only takes the connection, not the error. So an idle connection's error never reaches Pool — there's nothing for Pool to emit, and nothing for this PR's forwarding to forward.

Making Pool actually emit those errors would need PoolConnection to forward them upward, guarded by a listenerCount check — without that guard, any app that's never called pool.on('error', ...) would crash on the next idle connection error instead of it being silently dropped like today. That's a real behavior change across both the callback and promise APIs, not something I want to fold into this PR.

Scoping this PR back to what #3749 actually asked for: the type is missing for an event inheritEvents already lists, so I'll keep it to that and drop the error addition to inheritEvents/promise.d.ts unless you'd rather track the idle-connection-error gap separately.

@GiHoon1123

Copy link
Copy Markdown
Author

Correction on my last comment: inheritEvents didn't already list error before this PR — I added it (along with the promise.d.ts entry). Doesn't change the conclusion, just wanted the history accurate. Will drop both since Pool never actually emits error today.

Pool never emits 'error' itself - PoolConnection swallows connection
errors internally (once('error', () => this._removeFromPool())), so
the forwarding added here had nothing to forward. Scoping this back
to what sidorares#3749 actually needs.
@GiHoon1123

Copy link
Copy Markdown
Author

Closing this. Once the error-forwarding piece is dropped there's nothing left to add here - the original request was for a type on an event Pool doesn't actually emit. If the idle-connection-error gap is worth fixing, that's a separate, bigger change to PoolConnection's own error handling, not this PR.

@GiHoon1123 GiHoon1123 closed this Sep 19, 2026
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.

error event missing in types

3 participants