fix(cloudflare): Instrument DO RPC methods on the prototype, not a Proxy - #23057
Draft
JPeer264 wants to merge 1 commit into
Draft
fix(cloudflare): Instrument DO RPC methods on the prototype, not a Proxy#23057JPeer264 wants to merge 1 commit into
JPeer264 wants to merge 1 commit into
Conversation
Contributor
size-limit report 📦
|
Base automatically changed from
jp/cloudflare-remove-instrument-prototype-methods
to
develop
August 5, 2026 14:57
The RPC instrumentation returned a Proxy of the Durable Object instance. A Proxy never carries the class's native private-field brand, so any dispatch that resolves a method on the prototype and invokes it with the stored instance as receiver (native RPC/facet dispatch, Agents SDK setName() bootstrap) throws "Cannot read private member #x from an object whose class did not declare it" for classes using native private fields. Wrap RPC methods on the class prototype chain instead (once per class) and keep per-instance state in a WeakMap keyed on the instance, so the receiver is always the real branded instance on every dispatch path.
JPeer264
force-pushed
the
jp/cloudflare-agent-rpc-proxy-private-fields
branch
from
August 5, 2026 14:57
f8aa01f to
a504b21
Compare
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.
closes #23040
closes JS-3283
This is getting rid completely of the Proxy for methods on the DO entirely. It seems private calls were not working properly with Proxies, therefore we need to switch entirely to a prototype-wrapping. This was in already before in
instrumentPrototypeMethodsand moved over to a Proxy.I also did a benchmark on a deployed worker instance and it seems that there is no significant performance difference - they're even mostly the same in performance. So there is only a win doing this.
Clanker description:
The RPC instrumentation returned a Proxy of the Durable Object instance. A Proxy never carries the class's native private-field brand, so any dispatch that resolves a method on the prototype and invokes it with the stored instance as receiver (native RPC/facet dispatch, Agents SDK setName() bootstrap) throws "Cannot read private member #x from an object whose class did not declare it" for classes using native private fields.
Wrap RPC methods on the class prototype chain instead (once per class) and keep per-instance state in a WeakMap keyed on the instance, so the receiver is always the real branded instance on every dispatch path.