Using Durable Objects in Dev Environment

In my wrangler.toml file I have this structure:
[env.dev]
vars = { ENVIRONMENT = "dev" }

[env.staging]
vars = { ENVIRONMENT = "staging" }

[env.production]
vars = { ENVIRONMENT = "production" }
[env.dev]
vars = { ENVIRONMENT = "dev" }

[env.staging]
vars = { ENVIRONMENT = "staging" }

[env.production]
vars = { ENVIRONMENT = "production" }
I created a Durable Object at the top level and I get this message when I launch my Worker in dev mode:
- "env.dev" environment configuration
- "durable_objects" exists at the top level, but not on "env.dev".
This is not what you probably want, since "durable_objects" is not inherited by
environments.
Please add "durable_objects" to "env.dev".
- "env.dev" environment configuration
- "durable_objects" exists at the top level, but not on "env.dev".
This is not what you probably want, since "durable_objects" is not inherited by
environments.
Please add "durable_objects" to "env.dev".
So I changed my configuration and added this under the dev section:
[env.dev]
vars = { ENVIRONMENT = "dev" }

[[durable_objects.bindings]]
name = "MEMBER_COUNT_DEV"
class_name = "MemberCount"

[[migrations]]
tag = "v1"
new_classes = ["MemberCount"]
[env.dev]
vars = { ENVIRONMENT = "dev" }

[[durable_objects.bindings]]
name = "MEMBER_COUNT_DEV"
class_name = "MemberCount"

[[migrations]]
tag = "v1"
new_classes = ["MemberCount"]
But I still get the same message. This is not how you add DOs to environments. What am I doing wrong. I followed a similar example in the docs about adding a KV store to multiple environments.
1 Reply
danboyle8637
danboyle8637OP14mo ago
Of course I figured this out after I posted this. I always works out like that right? Ha! Here's the solution is anybody else has a similar problem:
[env.dev]
vars = { ENVIRONMENT = "dev" }

[[env.dev.durable_objects.bindings]]
name = "DO_NAME"
class_name = "DO_CLASS"
[env.dev]
vars = { ENVIRONMENT = "dev" }

[[env.dev.durable_objects.bindings]]
name = "DO_NAME"
class_name = "DO_CLASS"
Want results from more Discord servers?
Add your server