Skip to content

Conversation

@irvinebroque
Copy link
Contributor

@irvinebroque irvinebroque commented Jan 4, 2026

Extends the existing resource provisioning feature to support Cloudflare Queues. When users deploy with queue bindings configured, missing queues are now automatically created, just like KV, D1, and R2.

Changes:

  • Add QueueHandler class following the R2Handler pattern (name-based, no ID)
  • Add queue provisioning helper functions using ComplianceConfig
  • Collect and de-duplicate queues from both producers and consumers
  • Skip ensureQueuesExistByConfig when provisioning is enabled
  • Include delivery_delay in queue binding transformation
  • Update deploy tests to use --x-provision=false for legacy behavior tests

The feature is controlled by the existing --x-provision flag (enabled by default) and --x-auto-create flag for interactive vs automatic creation.

I've tested this out locally and deployed successfully. And reviewed code, left comments. Written with opencode.

Questions

  • Comfortable rolling this out as part of existing behavior without customers needing to add additional flags?

…system

Extends the existing resource provisioning feature to support Cloudflare Queues.
When users deploy with queue bindings configured, missing queues are now
automatically created, providing the same seamless experience as KV, D1, and R2.

Changes:
- Add QueueHandler class following the R2Handler pattern (name-based, no ID)
- Add queue provisioning helper functions using ComplianceConfig
- Collect and de-duplicate queues from both producers and consumers
- Skip ensureQueuesExistByConfig when provisioning is enabled
- Include delivery_delay in queue binding transformation
- Update deploy tests to use --x-provision=false for legacy behavior tests

The feature is controlled by the existing --x-provision flag (enabled by default)
and --x-auto-create flag for interactive vs automatic creation.
@changeset-bot
Copy link

changeset-bot bot commented Jan 4, 2026

🦋 Changeset detected

Latest commit: b0ac2a1

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@claude
Copy link
Contributor

claude bot commented Jan 4, 2026

Claude finished @irvinebroque's task —— View job


Changeset Review

Reviewing changeset files...

Tasks:

  • Read changeset guidelines
  • Review changeset file
  • Validate against criteria
  • Check for animal images

⚠️ Issues found

The changeset .changeset/queue-provisioning.md has the following issue:

Markdown Headers: The changeset uses code blocks with JSONC format which is good, but there's a comment in the review from petebacondarwin noting "We prefer JSONC config nowadays" on this file. Looking at the changeset, it already uses jsonc in the code block, so this appears to be addressed correctly.

However, the changeset has one minor formatting issue:

Line 11: The comment syntax in the example uses // wrangler.jsonc which suggests a JSONC file, but the actual Workers configuration files are typically named wrangler.toml (TOML format) or wrangler.json (JSON format). The comment should clarify this is showing JSONC format as an example, or use the more standard wrangler.toml TOML format that most users have.

Other validation results:
Version Type: Correctly set to minor (new feature)
Changelog Quality: Excellent description with clear examples and feature list
Markdown Headers: No h1/h2/h3 headers used (correctly uses h4 if any)
No forbidden major version for wrangler

The changeset is well-written overall with good examples and clear explanations. The only suggestion is to clarify the configuration format being shown or use the more standard TOML format.


@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 4, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@11788

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@11788

miniflare

npm i https://pkg.pr.new/miniflare@11788

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@11788

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@11788

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@11788

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@11788

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@11788

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@11788

wrangler

npm i https://pkg.pr.new/wrangler@11788

commit: b0ac2a1

@irvinebroque irvinebroque marked this pull request as ready for review January 4, 2026 03:47
@irvinebroque irvinebroque requested a review from a team as a code owner January 4, 2026 03:47
@petebacondarwin
Copy link
Contributor

@irvinebroque - was this PR generated by AI? If so, although you said you have reviewed it, can you mention this for transparency in the PR description?

// Skip queues - they use queue name from config, no ID write-back needed
if (resourceType === "queues") {
continue;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not obvious to me why this ended up being necessary, given that Queues should behave like R2 and I don't see equivalent here for R2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are noops since the binding will be identical and the patch function below will find no difference.
So I think you can remove this check and the one below to simplify this code.

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting to see this implemented but I think we can be a bit cleaner with the approach.

return mock;
}

// Legacy helpers for backwards compatibility
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this comment is accurate. These helpers are not legacy nor related to backward compatibility. I would just delete this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Skip queues - they use queue name from config, no ID write-back needed
if (resourceType === "queues") {
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are noops since the binding will be identical and the patch function below will find no difference.
So I think you can remove this check and the one below to simplify this code.

bindings: CfWorkerInit["bindings"],
requireRemote: boolean
requireRemote: boolean,
config?: Config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than add a new parameter, just repurpose the complianceConfig parameter above. The actual object that is passed in there is always a Config anyway...

async function collectPendingResources(
	config: Config,
	accountId: string,
	scriptName: string,
	bindings: CfWorkerInit["bindings"],
	requireRemote: boolean
}

Comment on lines 574 to 577
const resources =
resourceType === "queues" && config
? collectUniqueQueueBindings(config)
: bindings[resourceType] ?? [];
Copy link
Contributor

@petebacondarwin petebacondarwin Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than special casing here, I would rather we use polymorphism by adding a new method to the ProvisionResourceHandler class that returns the binding:

getResourcesFromConfig(config: Config | undefined, bindings: B[]) {
  return bindings;
}

and then in the QueueHandler class:

getResourcesFromConfig(config: Config | undefined, bindings: B[]) {
  assert(config);
  return collectUniqueQueueBindings(config);
}

and the call site would look like:

		const resources = HANDLERS[resourceType].getResourcesFromConfig(config, bindings[resourceType] ?? []);

@github-project-automation github-project-automation bot moved this from Untriaged to In Review in workers-sdk Jan 6, 2026
Ensures queue producer bindings include the `remote` field, matching
the pattern used by R2 and other bindings that support remote mode.
Rather than special-casing queues in collectPendingResources, add a
getResourcesFromConfig method to each handler in HANDLERS that can be
overridden per resource type. QueueHandler's method calls
collectUniqueQueueBindings to collect both producers and consumers.

Also simplifies the function signature by using Config directly instead
of ComplianceConfig, since Config is always passed in practice.
Clarify that the queue skipping in config patching is required because:
1. config.queues has a different shape (producers/consumers) than other
   bindings which are flat arrays
2. Queues use name-based identification so no ID write-back is needed
The mockListQueues and mockCreateQueue helpers are standard test
utilities, not legacy helpers for backwards compatibility.
Comment on lines +448 to +451
getResourcesFromConfig: (
_config: Config,
bindings: CfKvNamespace[]
): CfKvNamespace[] => bindings,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion was for this to be a method on the handler (e.g. here KVHandler. The "standard" implementation will be on ProvisionResourceHandler and only the QueueHandler needs the method to be overridden.

Moreover, I believe that this method can use a type parameter to avoid having to cast the return values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants