Conversation
🦋 Changeset detectedLatest commit: 3729bb9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6b219f14a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| return promise.then.bind(promise); | ||
| } | ||
| return Reflect.get(obj, prop, receiver); |
There was a problem hiding this comment.
Preserve target receiver when exposing instance members
The get trap returns non-then members via Reflect.get(obj, prop, receiver), so method/getter calls execute with this bound to the proxy instead of the real instance. For classes that use ECMAScript private fields (#field), this triggers runtime brand-check failures (Cannot read private member ...) as soon as a proxied method/getter is invoked, which breaks the “fully functional” guarantee of makeAwaitable and can crash any awaitable wrapper around such classes.
Useful? React with 👍 / 👎.
Create a utility that wraps a class constructor so that instances are both fully functional (all original properties/methods) and awaitable via a user-provided handler.
This mirrors Python's
__await__protocol. In JS,awaitworks on any "thenable" (object with a.then()method), so the returned constructor produces instances with a transparent.thenthat delegates to the handler.The returned class is safe to
extends— subclass prototype chains are preserved viaReflect.constructwithnewTargetforwarding.This class is intended to be used for
AgentTaskandSpeechHandleso developer can easily do await directly on the object instead of callingawait new AgentTask().run()andawait new SpeechHandle().waitForPlayout()(tho both method will remain backward competible)