Skip to content

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

@kentonv

Description

@kentonv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions