diagnostics_channel: return original thenable#62407
Open
Qard wants to merge 1 commit intonodejs:mainfrom
Open
Conversation
rochdev
reviewed
Mar 23, 2026
This makes tracePromise return the original thenable to allow custom thenable types to retain their methods rather than producing the chained result type.
fc213c4 to
3eb07ea
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62407 +/- ##
=======================================
Coverage 89.68% 89.69%
=======================================
Files 676 676
Lines 206710 206720 +10
Branches 39584 39585 +1
=======================================
+ Hits 185398 185417 +19
- Misses 13441 13442 +1
+ Partials 7871 7861 -10
🚀 New features to boost your workflow:
|
mhofman
reviewed
Mar 23, 2026
Renegade334
reviewed
Mar 24, 2026
Member
Renegade334
left a comment
There was a problem hiding this comment.
Does this change have a specific case in mind? The A+ standard mandates .then() to return another "promise" instance (either the same object or a new object at the implementation's discretion), so any custom features of a compliant thenable should also be present on the object returned by .then()?
Comment on lines
+404
to
+405
| // TODO(qard): Not realm safe? Should be a construct.name check? | ||
| if (result.constructor === Promise) { |
Member
There was a problem hiding this comment.
require('internal/util/types').isPromise()?
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.
This makes tracePromise return the original thenable to allow custom thenable types to retain their methods rather than producing the chained result type.
This branches the behaviour between native promises and thenables such that native promises retain the correct unhandledRejection behaviour while thenables produce the correct original return value and so retain methods present on that type.
I think that because native promises are consistently shaped it doesn't actually matter that it remains chained rather than branched.
cc @nodejs/diagnostics