Skip to content

move triggers deploy into deploy-helpers #14069

Draft
emily-shen wants to merge 5 commits into
emily/cfetch-workers-utilsfrom
emily/triggers-2
Draft

move triggers deploy into deploy-helpers #14069
emily-shen wants to merge 5 commits into
emily/cfetch-workers-utilsfrom
emily/triggers-2

Conversation

@emily-shen
Copy link
Copy Markdown
Contributor

@emily-shen emily-shen commented May 27, 2026

move triggers deploy into deploy-helpers - this is a nice smaller unit of the deploy path to pull out.

some minor refactoring to the triggers deploy command as well to do validation up front.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: refactor, should pass existing tests
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because:

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 27, 2026

⚠️ No Changeset found

Latest commit: 514371b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@emily-shen emily-shen changed the title Emily/triggers 2 move triggers deploy into deploy-helpes May 27, 2026
@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk May 27, 2026
@workers-devprod workers-devprod requested review from a team and penalosa and removed request for a team May 27, 2026 17:55
@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/deploy-helpers/package.json: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/index.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/shared/types.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/triggers/deploy.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/triggers/publish-routes.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/triggers/queue-consumers.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/triggers/subdomain.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/triggers/zones.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/tsup.config.ts: [@cloudflare/wrangler]
  • packages/workers-utils/package.json: [@cloudflare/wrangler]
  • packages/workers-utils/src/cfetch/index.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/format-time.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/index.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/is-interactive.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/retry.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/workers-dev.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/helpers/mock-upload-worker.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/assets.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deploy/config-diffs.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deploy/deploy.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/resolve-config-args.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/triggers/deploy.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/triggers/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/utils/useServiceEnvironments.ts: [@cloudflare/wrangler]
  • pnpm-lock.yaml: [@cloudflare/wrangler]

@emily-shen emily-shen changed the title move triggers deploy into deploy-helpes move triggers deploy into deploy-helpers May 27, 2026
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

This PR moves trigger deployment logic from wrangler into deploy-helpers, introducing a TriggerProps type and DeployHelpersContext for dependency injection. It also lifts retryOnAPIFailure, formatTime, and isNonInteractiveOrCI into workers-utils.

Issues (ranked by severity):

  1. Bug: Config-file cron triggers are silently dropped in wrangler deploy — In the deploy/deploy.ts call to triggersDeploy, crons is set to props.triggers (the CLI --triggers arg) without falling back to config.triggers?.crons. The old code had const schedules = props.triggers || config.triggers?.crons. This means crons defined in wrangler.json will no longer be deployed when running wrangler deploy (without --triggers). The wrangler triggers deploy path handles this correctly via resolveTriggersInput, but the main deploy path does not.

accountId,
scriptName,
env: props.env,
crons: props.triggers,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: This drops the config-file fallback for cron triggers. Previously, the old triggersDeploy computed schedules = props.triggers || config.triggers?.crons, so config-defined crons were deployed even when --triggers wasn't passed on the CLI. Now props.triggers is undefined in that case and crons will be undefined, silently skipping cron deployment.

Suggested change
crons: props.triggers,
crons: props.triggers || config.triggers?.crons,

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 27, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR moves trigger deployment logic from wrangler into deploy-helpers, introducing a TriggerProps type and DeployHelpersContext for dependency injection. It also lifts retryOnAPIFailure, formatTime, and isNonInteractiveOrCI into workers-utils.

Issue found:

  1. Bug: Config-file cron triggers are silently dropped in wrangler deploy — In packages/wrangler/src/deploy/deploy.ts:1323, crons is set to props.triggers (the CLI --triggers arg) without falling back to config.triggers?.crons. The old code computed schedules = props.triggers || config.triggers?.crons, so config-defined crons were always deployed. Now when --triggers isn't passed, crons will be undefined and cron deployment will be silently skipped. The wrangler triggers deploy path handles this correctly via resolveTriggersInput, but the main wrangler deploy path does not. I posted a suggestion comment with the fix.

github run

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment on lines +1316 to 1327
assert(accountId);
// deploy triggers
const targets = await triggersDeploy({
...props,
config,
accountId,
scriptName,
env: props.env,
crons: props.triggers,
useServiceEnvironments,
firstDeploy: !workerExists,
routes: allDeploymentRoutes,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 ensureQueuesExistByConfig dropped from wrangler deploy path

The old triggersDeploy in wrangler/src/triggers/deploy.ts called ensureQueuesExistByConfig(config) before proceeding with deployment, ensuring that all queues referenced in config actually exist. The new implementation in deploy-helpers/src/triggers/deploy.ts does not call ensureQueuesExistByConfig (it's a wrangler-specific function that depends on requireAuth). While ensureQueuesExistByConfig was correctly added to the wrangler triggers deploy handler at packages/wrangler/src/triggers/index.ts:76, it was not added to the wrangler deploy path in packages/wrangler/src/deploy/deploy.ts. This means users running wrangler deploy with non-existent queues in their config will no longer get a helpful early validation error and will instead encounter confusing API errors later during consumer registration.

Prompt for agents
In the wrangler deploy path (packages/wrangler/src/deploy/deploy.ts), the call to ensureQueuesExistByConfig(config) was previously performed inside the old triggersDeploy function (which lived in wrangler/src/triggers/deploy.ts). During the refactor to deploy-helpers, this call was lost because ensureQueuesExistByConfig depends on wrangler-specific auth (requireAuth) and cannot live in the shared package.

The fix for the wrangler triggers deploy command was done correctly: ensureQueuesExistByConfig is called at packages/wrangler/src/triggers/index.ts:76 before calling triggersDeploy.

The same pattern needs to be applied to the wrangler deploy path. Add a call to ensureQueuesExistByConfig(config) in packages/wrangler/src/deploy/deploy.ts, just before the triggersDeploy call around line 1317. You will need to import ensureQueuesExistByConfig from ../queues/client.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@emily-shen emily-shen marked this pull request as draft May 27, 2026 17:58
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 27, 2026

create-cloudflare

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

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14069

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 514371b

@penalosa penalosa force-pushed the emily/cfetch-workers-utils branch 2 times, most recently from 584e6cb to dc99f13 Compare May 29, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants