fix(cloudflare): use correct Proxy receiver in instrumentDurableObjectStorage#19662
Merged
nicohrubec merged 2 commits intogetsentry:developfrom Mar 6, 2026
Conversation
…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.
5e71dc4 to
1cef324
Compare
nicohrubec
approved these changes
Mar 6, 2026
Member
nicohrubec
left a comment
There was a problem hiding this comment.
Thanks for contributing! I have updated the tests a bit since I think most are redundant with the existing test suite but else lgtm.
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.
Summary
Fixes #19661
instrumentDurableObjectStorage's Proxygettrap passesreceiver(the proxy) toReflect.get, breaking native workerd getters likestorage.sqlthat validatethisvia internal slots.Reflect.get(target, prop, receiver)→Reflect.get(target, prop, target)so native getters execute with the real storage object asthisDetails
The
sqlproperty onDurableObjectStorageis a native getter that requires the real native object asthis. When the Proxy'sgettrap callsReflect.get(target, prop, receiver), the getter runs withthis= proxy → "Illegal invocation". Usingtargetas 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 (likesql).Regression tests use a
BrandCheckedStorageclass with private fields — accessing#sqlInstanceon the wrongthisthrows TypeError, faithfully simulating workerd's native internal-slot validation.