fix: propagate fatal flag across all promise wrapper error paths#4196
Open
techcodie wants to merge 1 commit intosidorares:masterfrom
Open
fix: propagate fatal flag across all promise wrapper error paths#4196techcodie wants to merge 1 commit intosidorares:masterfrom
techcodie wants to merge 1 commit intosidorares:masterfrom
Conversation
The promise wrapper layer had two related issues: 1. fatal flag was silently dropped in ping(), connect(), prepare(), changeUser() in PromiseConnection, and end() in PromisePool. These methods manually copied a fixed set of error properties (message, code, errno, sqlState, sqlMessage) but omitted fatal, meaning promise clients could not distinguish fatal errors from non-fatal ones — unlike callback clients which always receive it. 2. The same manual copy block was duplicated across 5 methods with no shared abstraction, making it easy to miss properties (as demonstrated by the missing fatal flag). Fix: extract assignError() helper in make_done_cb.js that copies all error properties including fatal, and use it in all promise wrapper error paths. Also fixes PromisePool.execute args check (if (args) -> if (args !== undefined)) to be consistent with PromisePool.query.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4196 +/- ##
==========================================
- Coverage 90.64% 90.58% -0.07%
==========================================
Files 86 86
Lines 14245 14233 -12
Branches 1798 1801 +3
==========================================
- Hits 12913 12893 -20
- Misses 1332 1340 +8
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
The promise wrapper layer had two related issues:
1.
fatalflag silently dropped in 5 methodsping(),connect(),prepare(),changeUser()inPromiseConnectionandend()inPromisePoolall manually copied a fixed set of error properties tolocalErrbefore rejecting:But
err.fatalwas never copied. This means promise clients calling these methods could not distinguish fatal errors (e.g.PROTOCOL_CONNECTION_LOST,ECONNREFUSED) from non-fatal ones — a silent behavioral difference from the callback API which always receivesfatal.2. Same copy block duplicated 5 times with no shared abstraction
The repetition is what caused the omission in the first place — there was no single place to add a new property.
Fix
assignError(localErr, err)helper inmake_done_cb.jsthat copies all error properties includingfatal, and export itpromise/connection.jsandpromise/pool.jswithassignError()makeDoneCbitself also usesassignErrornow for consistencyPromisePool.executefalsyargscheck (if (args)→if (args !== undefined)) to be consistent withPromisePool.queryTests
Added
test/integration/promise-wrappers/test-promise-connection-error-properties.test.mtscoveringping,connect,prepare, andchangeUsererror propagation.