itty-durable icon indicating copy to clipboard operation
itty-durable copied to clipboard

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

Open kentonv opened this issue 3 months ago • 1 comments

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.

https://github.com/kwhitley/itty-durable/blob/86c8f0161755e7054771b5c022c135bf1ac5ffc4/src/itty-durable.js#L32-L36

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.

kentonv avatar Mar 19 '24 20:03 kentonv