feat(pool): add getStats() diagnostics method and fix execute() argument normalization#4266
Open
IshitaSingh0822 wants to merge 7 commits intosidorares:masterfrom
Open
feat(pool): add getStats() diagnostics method and fix execute() argument normalization#4266IshitaSingh0822 wants to merge 7 commits intosidorares:masterfrom
IshitaSingh0822 wants to merge 7 commits intosidorares:masterfrom
Conversation
…ent normalization
Owner
|
Hi @IshitaSingh0822 thanks for the contribution! some notes:
|
Author
|
Hi @sidorares, thanks for the feedback! I've addressed all the points:
Happy to make any further changes if needed! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4266 +/- ##
==========================================
- Coverage 90.87% 90.86% -0.02%
==========================================
Files 89 89
Lines 14501 14545 +44
Branches 1864 1872 +8
==========================================
+ Hits 13178 13216 +38
- Misses 1323 1329 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Two improvements to
BasePoolinlib/base/pool.js:1. Fix
pool.execute()argument normalization (||→??)When calling
execute(optionsObject, externalValues, cb), the original code used:This silently discards a valid
options.valuesif it happens to be falsy.Replaced with nullish coalescing so only a truly absent value falls back:
Also changed the
catchblock in the no-callback path to emit on the poolinstead of throwing, keeping behavior consistent with
pool.query().2. Add
pool.getStats()diagnostics methodReturns a lightweight snapshot of pool state — useful for health checks,
metrics exporters, and debugging pool exhaustion without reaching into
private internals:
Files changed
lib/base/pool.js??fix inexecute(); newgetStats(); emit instead of throw in no-cb catchtest/unit/test-pool-execute-polymorphic.test.cjstypings/mysql/lib/pool.d.tsPoolStatsinterface +getStats(): PoolStatsdeclarationTest results
PASS › 175 FAIL › 0
Full suite passed including integration tests against a live MySQL server via Docker.
Notes
getStats()returns a plain object snapshot, not a live/reactive viewqueueLimit: 0in stats means unlimited, matching pool config semantics