Repository navigation
tracingChannel.tracePromise forces native promises #59936
Description
Activity
- addeddiagnostics_channelIssues and PRs related to the diagnostics_channel module.Issues and PRs related to the diagnostics_channel module.
on Sep 20, 2025 This fits the documentation which says Promise Chained from promise returned by the given function
I think for functions which are not fitting into the standard sync/callback/pattern require some hand crafted variant which fits to the lifecycle/api of the concrete object returned.
This fits the documentation which says Promise Chained from promise returned by the given function
This behaviour is currently conditional on the presence or absence of channel subscribers, and the handling of non-thenables is also variable, so there does at least need to be some formal codification of what the behaviour should be.
Reacted by James SumnersI think
traceCallbackhas a similar issue. If the given callback has some extra properties set they are missing on the wrapped callback. if the called API is relying on them it likely results in problems.
AlsowrappedCallback.lengthmight differ from original.Likely not that frequently occurring in the wild compared to thenables/custom promises.
The native promise upgrade is required for PromisePrototypeThen to work correctly.
We could eliminate the use of the primordial there. I don't recall if the primordials discussion ever came to some clear conclusion, but I know there at least was some discussion that maybe those don't matter?
I think even if we would not use
PromisePrototypeThenthe conversion/assumption for aPromiseis needed/will happen.
Athenableis an object having athen()function. WhilePromise#then()returns aPromisethere is no requirement forThenable#then()to return anything.A
thenableis an object having athen()function. WhilePromise#then()returns aPromisethere is no requirement forThenable#then()to return anything.A+ does mandate this, so it's not a thoroughly unreasonable assumption.
- added a commit that references this issue
on Mar 17, 2026 - added a commit that references this issue
on Aug 10, 2026 - added a commit that references this issue
on Aug 13, 2026 - added a commit that references this issue
on Aug 25, 2026
Version
18.19.0+
Platform
Subsystem
diagnostics_channel
What steps will reproduce the bug?
We received a report about an openai method crashing that's been wrapped with
tracingChannel.tracePromise. After some digging, I see the issues is here. OpenAI creates a custom promise and it's getting stripped in tracePromise. This is a distilled repro case to show the issue.How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior? Why is that the expected behavior?
To properly return the custom promise
What do you see instead?
It returns a native Promise instead
Additional information
I could workaround this by using
traceSyncand propagating the promise myself, but I'd prefer that the API does the right thing.