diagnostics_channel: ensure tracePromise consistency with non-Promises#61766
Open
Renegade334 wants to merge 1 commit intonodejs:mainfrom
Open
diagnostics_channel: ensure tracePromise consistency with non-Promises#61766Renegade334 wants to merge 1 commit intonodejs:mainfrom
Renegade334 wants to merge 1 commit intonodejs:mainfrom
Conversation
Renegade334
commented
Feb 10, 2026
| // TODO: Is there a way to have asyncEnd _after_ the continuation? | ||
| asyncEnd.publish(context); | ||
| return PromiseReject(err); | ||
| throw err; |
Member
Author
There was a problem hiding this comment.
Throwing here avoids Promisifying thenables on rejection. The Promises/A+ standard dictates that throwing within the promise handlers results in the returned thenable rejecting. (https://promisesaplus.com/#point-42)
For native Promises, there should be no observable change.
b54c7f4 to
71a5eb2
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61766 +/- ##
=======================================
Coverage 89.74% 89.75%
=======================================
Files 675 675
Lines 204642 204650 +8
Branches 39322 39325 +3
=======================================
+ Hits 183657 183683 +26
+ Misses 13257 13251 -6
+ Partials 7728 7716 -12
🚀 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.
tracingChannel.tracePromise()is documented in the source code (albeit not in the docs) to accept functions that return non-Promise thenables. However, it currently has some wonky behaviour when the return value isn't a native Promise, and also in the undocumented case where the return value isn't promise-like at all.What gets returned by
tracePromise()is highly dependent on whether the tracing channel has active subscribers or not:resulttyperesultresult.then(...)resultPromise.resolve(result).then(...)resultPromise.resolve(result).then(...)The major inconsistencies are:
asyncStart/asyncEndevents, despite no asynchronous execution. On the other hand, if the wrapped function throws synchronously, these events are not produced.This PR makes some changes to the non-Promise cases to make the behaviours consistent.
result.then(...)(if active subscribers).asyncStartorasyncEndevents are produced.resulttyperesultresult.then(...)resultresult.then(...)resultresultFixes: #59936