move triggers deploy into deploy-helpers #14069
Conversation
…nAPIFailure, formatTime, isNonInteractiveOrCI)
|
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
There was a problem hiding this comment.
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):
- Bug: Config-file cron triggers are silently dropped in
wrangler deploy— In thedeploy/deploy.tscall totriggersDeploy,cronsis set toprops.triggers(the CLI--triggersarg) without falling back toconfig.triggers?.crons. The old code hadconst schedules = props.triggers || config.triggers?.crons. This means crons defined inwrangler.jsonwill no longer be deployed when runningwrangler deploy(without--triggers). Thewrangler triggers deploypath handles this correctly viaresolveTriggersInput, but the main deploy path does not.
| accountId, | ||
| scriptName, | ||
| env: props.env, | ||
| crons: props.triggers, |
There was a problem hiding this comment.
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.
| crons: props.triggers, | |
| crons: props.triggers || config.triggers?.crons, |
|
I'm Bonk, and I've done a quick review of your PR. This PR moves trigger deployment logic from wrangler into Issue found:
|
| assert(accountId); | ||
| // deploy triggers | ||
| const targets = await triggersDeploy({ | ||
| ...props, | ||
| config, | ||
| accountId, | ||
| scriptName, | ||
| env: props.env, | ||
| crons: props.triggers, | ||
| useServiceEnvironments, | ||
| firstDeploy: !workerExists, | ||
| routes: allDeploymentRoutes, | ||
| }); |
There was a problem hiding this comment.
🔴 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
739c77b to
514371b
Compare
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
584e6cb to
dc99f13
Compare
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.
A picture of a cute animal (not mandatory, but encouraged)