Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identifying DO namespaces by the existence of idFromName will soon have false positives #48

Open
kentonv opened this issue Mar 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@kentonv
Copy link

kentonv commented Mar 19, 2024

itty-durable currently scans all bindings (the contents of env) to find Durable Object namespace bindings. It decides that a binding is a DO namespace if it has a method idFromName.

for (const [key, binding] of Object.entries(env)) {
this.state[key] = typeof binding.idFromName === 'function'
? proxyDurable(binding, { name: key, parse: true })
: binding
}

In the near future, Workers will introduce a binding type that is a proxy object which appears to have methods of every possible name. Hence, this binding type will incorrectly be detected as a Durable Object namespace.

It appears the effects of this are mostly benign, but it might be worth tightening the test. I think you could perhaps detect these proxy objects by also checking for the presence of an unlikely method name, like __methodThatWillNeverBeDefined or something. If that exists and is a function, you are probably looking at a proxy and not a DO namespace.

@kwhitley
Copy link
Owner

Awesome catch - I appreciate the heads up!

@kwhitley kwhitley added the bug Something isn't working label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants