Worker service binding undefined

I’m in need of some help with setting up service bindings.

I have successfully bound a service worker to another worker (confirmed in wrangler response and the worker settings in the dashboard), but the binding is not defined on the environment of the gateway worker. If I log the keys of the environment, I get all I expect there - environment variables and kv binding names, but the service binding is missing. It is defined in wrangler.toml as:

services = [
    { binding = "generate_invoice", service = "cfworker-transact-generate-invoice", environment = "production" }
]

I’ve tried the alternate syntax but that failed to even create the binding in wrangler.

The usage is basic right now for testing:

export default {
    async fetch(request, env, context) {
        env.generate_invoice.fetch(new Request())
        return new Response('called')
    }
}

I get the response Cannot read properties of undefined (reading 'fetch') every time.
Using wrangler 2.0.16

Is there something additional I’m missing to enable these bindings?

Are you publishing the Worker and then getting this error back with wrangler tail?

Yes, the worker is published. I was using quickedit in the dashboard to test it.

I don’t think Quick Edit/Preview has service bindings support.

Looks like that was it. Thank you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.