fix: propagate fatal flag in promise error wrapper and fix execute args check#4193
Open
techcodie wants to merge 2 commits intosidorares:masterfrom
Open
fix: propagate fatal flag in promise error wrapper and fix execute args check#4193techcodie wants to merge 2 commits intosidorares:masterfrom
techcodie wants to merge 2 commits intosidorares:masterfrom
Conversation
…gs check - makeDoneCb now copies err.fatal to the rejected localErr, so promise clients receive the same fatal property that callback clients do. Previously, fatal errors (e.g. PROTOCOL_CONNECTION_LOST) would reject with an error missing the fatal flag, making it impossible for callers to distinguish fatal from non-fatal errors. - PromisePool.execute used a falsy check (if (args)) instead of (if (args !== undefined)), inconsistent with PromisePool.query. This is now aligned to use strict undefined check.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4193 +/- ##
=======================================
Coverage 90.64% 90.65%
=======================================
Files 86 86
Lines 14245 14246 +1
Branches 1798 1798
=======================================
+ Hits 12913 12914 +1
Misses 1332 1332
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.
Problem
Two related bugs in the promise wrapper layer:
1.
fatalflag lost in promise rejections (make_done_cb.js)When a fatal error occurs (e.g.
PROTOCOL_CONNECTION_LOST), the callback API correctly setserr.fatal = true. However,makeDoneCb— used by all promise-based methods (query,execute,beginTransaction, etc.) — was not copyingerr.fatalto the rejectedlocalErr.This meant promise clients had no way to distinguish fatal errors from non-fatal ones, a silent behavioral difference from the callback API.
2.
PromisePool.executeused a falsyargscheck (pool.js)PromisePool.querycorrectly usesif (args !== undefined)butPromisePool.executeusedif (args). These should be consistent.Fix
lib/promise/make_done_cb.js: addlocalErr.fatal = err.fatallib/promise/pool.js: changeif (args)→if (args !== undefined)Tests
Added
test/integration/promise-wrappers/test-promise-error-properties.test.mtscovering both fixes.