Skip to content

fix(cloudflare): use correct Proxy receiver in instrumentDurableObjectStorage#19662

Open
dmmulroy wants to merge 1 commit intogetsentry:developfrom
dmmulroy:fix/cloudflare-do-storage-sql-illegal-invocation
Open

fix(cloudflare): use correct Proxy receiver in instrumentDurableObjectStorage#19662
dmmulroy wants to merge 1 commit intogetsentry:developfrom
dmmulroy:fix/cloudflare-do-storage-sql-illegal-invocation

Conversation

@dmmulroy
Copy link

@dmmulroy dmmulroy commented Mar 5, 2026

Summary

Fixes #19661

instrumentDurableObjectStorage's Proxy get trap passes receiver (the proxy) to Reflect.get, breaking native workerd getters like storage.sql that validate this via internal slots.

  • Change Reflect.get(target, prop, receiver)Reflect.get(target, prop, target) so native getters execute with the real storage object as this
  • Add regression tests using a class with private fields to simulate workerd's native brand-checked getters

Details

The sql property on DurableObjectStorage is a native getter that requires the real native object as this. When the Proxy's get trap calls Reflect.get(target, prop, receiver), the getter runs with this = proxy → "Illegal invocation". Using target as receiver ensures native getters always run against the real storage object.

Instrumented KV methods (get, put, delete, list) were unaffected because they're functions that get explicitly .bind(target)ed or called via .apply(target, args). The bug only manifests for non-function getters (like sql).

Regression tests use a BrandCheckedStorage class with private fields — accessing #sqlInstance on the wrong this throws TypeError, faithfully simulating workerd's native internal-slot validation.

…tStorage

The storage Proxy's get trap passed `receiver` (the proxy itself) to
`Reflect.get`, causing native workerd getters like `storage.sql` to
throw 'Illegal invocation' due to failed internal slot / brand checks.

Use `target` as the receiver so native getters execute with the correct
`this` binding.
@dmmulroy dmmulroy force-pushed the fix/cloudflare-do-storage-sql-illegal-invocation branch from 5e71dc4 to 1cef324 Compare March 5, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

instrumentDurableObjectStorage Proxy breaks native storage.sql getter (Illegal invocation)

1 participant