Conversation
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c0d0931. Configure here.
size-limit report 📦
|
| return instrumentFetcher((...args) => Reflect.apply(value, target, args)); | ||
| } | ||
|
|
||
| if (prop === 'connect' && typeof value === 'function') { | ||
| return (...args: unknown[]) => Reflect.apply(value, target, args); | ||
| } | ||
|
|
||
| if ( | ||
| propagateRpcTrace && | ||
| typeof value === 'function' && |
There was a problem hiding this comment.
Bug: The dup() method on instrumented Durable Object stubs is returned unbound. Calling stub.dup() will cause an "Illegal invocation" error.
Severity: HIGH
Suggested Fix
Add a handler for the dup method in the instrumentDurableObjectStub proxy, similar to the existing handler for connect. This will ensure dup is correctly bound using Reflect.apply(value, target, args) before being returned, preventing the "Illegal invocation" error.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
packages/cloudflare/src/instrumentations/instrumentDurableObjectNamespace.ts#L65-L74
Potential issue: The proxy handler for instrumented Durable Object stubs in
`instrumentDurableObjectStub` correctly handles the `connect` method by binding it, but
it fails to do the same for the `dup` method. Both methods are listed in
`STUB_NON_RPC_METHODS` and should be excluded from RPC tracing but still function
correctly. When `dup` is accessed, the proxy falls through and returns the method
unbound. Any subsequent call to `stub.dup()` will fail with an "Illegal invocation"
error because `this` is not correctly bound to the stub instance.
Also affects:
packages/cloudflare/src/instrumentations/worker/instrumentEnv.ts:101~110
Did we get this right? 👍 / 👎 to inform future reviews.
…nd DO stubs The service binding and Durable Object stub proxies returned connect() unbound, so calling it ran the native method with the proxy as `this` and workerd threw "Illegal invocation". The proxies cannot bind every function, because reading `.bind` on an RPC method returns another RPC property, so only connect() is forwarded to the binding. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
c0d0931 to
c0611fe
Compare
Found while fixing #24590: the service binding and Durable Object stub proxies have the same problem with
connect(). It is returned unbound, soenv.SERVICE.connect()andstub.connect()throw "Illegal invocation" on an instrumented env, with or without RPC trace propagation.Unlike the Queue fix, these proxies cannot bind every pass-through function: reading
.bindon an RPC method returns another RPC property (ping.bind) and would break RPC calls. So onlyconnect()is forwarded to the binding.Local workerd rejects an incoming CONNECT on a Worker after the
thischeck, so the integration test can only assert that the service binding no longer throws "Illegal invocation". The Durable Object stub call succeeds end to end.🤖 Generated with Claude Code