Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Use services instead of experimental_services in wrangler.toml #280

Closed
mrbbot opened this issue Jun 9, 2022 · 0 comments
Closed

Use services instead of experimental_services in wrangler.toml #280

mrbbot opened this issue Jun 9, 2022 · 0 comments
Labels
behaviour mismatch Different behaviour to Workers runtime
Milestone

Comments

@mrbbot
Copy link
Contributor

mrbbot commented Jun 9, 2022

Now that service bindings are generally available, it doesn't make sense to use the previous experimental_services wrangler.toml configuration key. Instead we should use services as described here: https://developers.cloudflare.com/workers/wrangler/configuration/.

This should be as simple as replacing the key here, since the format is exactly the same:

fromWrangler: ({ experimental_services }) =>
experimental_services?.reduce(
(services, { name, service, environment }) => {
services[name] = { service, environment };
return services;
},
{} as ServiceBindingsOptions
),

@mrbbot mrbbot added the behaviour mismatch Different behaviour to Workers runtime label Jun 9, 2022
@mrbbot mrbbot added this to the 2.6.0 milestone Jun 9, 2022
@mrbbot mrbbot closed this as completed in b3c1df4 Jun 11, 2022
jrencz added a commit to jrencz/miniflare that referenced this issue Jul 3, 2022
I noticed that in Workers docs and Miniflare there's inconsistency in how
services are declared:

- Workers expect `binding` key
https://github.com/cloudflare/cloudflare-docs/blob/a65a35843ffb7b69caf2758cc5f2ad805251d166/content/workers/wrangler/configuration.md?plain=1#L212-L220

- Miniflare expects `name`

I added 2 graceful and 2 error scenarios:
- (graceful) accept `name` with warning if `binding` is missing
- (graceful) accept `name` and `binding` both given and the same
- (error) throw if both `binding` and `name` are given but they don't match
- (error) throw if neither `binding` not `name` is given

I decided to handle it with errors, not with mutually exclusive presence
of either `name` or `binding` in interface `WranglerServiceConfig`
because `name` should go away - it's just a behavior mismatch.

Related: cloudflare#280
Syntax in wrangler2: cloudflare/workers-sdk#906
mrbbot pushed a commit that referenced this issue Jul 9, 2022
)

* Allow helper `parsePluginWranglerConfig` to be given `Log` instances

* Fix inconsistency: services have `binding` not `name` in `wrangler.toml`

I noticed that in Workers docs and Miniflare there's inconsistency in how
services are declared:

- Workers expect `binding` key
https://github.com/cloudflare/cloudflare-docs/blob/a65a35843ffb7b69caf2758cc5f2ad805251d166/content/workers/wrangler/configuration.md?plain=1#L212-L220

- Miniflare expects `name`

I added 2 graceful and 2 error scenarios:
- (graceful) accept `name` with warning if `binding` is missing
- (graceful) accept `name` and `binding` both given and the same
- (error) throw if both `binding` and `name` are given but they don't match
- (error) throw if neither `binding` not `name` is given

I decided to handle it with errors, not with mutually exclusive presence
of either `name` or `binding` in interface `WranglerServiceConfig`
because `name` should go away - it's just a behavior mismatch.

Related: #280
Syntax in wrangler2: cloudflare/workers-sdk#906
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
behaviour mismatch Different behaviour to Workers runtime
Projects
None yet
Development

No branches or pull requests

1 participant