cloudflare / cloudflare/workers-sdk
🐛 BUG: `getPlatformProxy`'s binding methods should throw `illegal invocation` errors like workerd does
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 187
Description
### Which Cloudflare product(s) does this pertain to?
Wrangler core
### What version(s) of the tool(s) are you using?
wrangler@3.63.0
### What version of Node are you using?
20
### What operating system and version are you using?
Mac
### Describe the Bug
### Observed behavior
When using `getPlatformProxy` destructuring methods from bindings works without erroring.
For example the following code would work:
```js
import { getPlatformProxy } from 'wrangler';
const { env: { MY_KV: { set } } } = await getPlatformProxy();
await set(key, value);
```
but trying to do the same in workerd would result in an `illegal invocation` error being thrown by the destructured `set` method (I've only tested this locally, I need to double check, but I assume that the same behavior applies in production).
### Expected behavior
bindings detached methods (like `set` above) should throw `illegal invocation` errors like they do in workerd, so that we don't create diverging behaviors/confusions for users.
### Please provide a link to a minimal reproduction
_No response_
### Please provide any relevant error logs
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.