Skip to content

Add --show-diff flag to wrangler triggers deploy#14114

Draft
dario-piotrowicz wants to merge 1 commit into
mainfrom
dario/triggers-deploy-diff
Draft

Add --show-diff flag to wrangler triggers deploy#14114
dario-piotrowicz wants to merge 1 commit into
mainfrom
dario/triggers-deploy-diff

Conversation

@dario-piotrowicz
Copy link
Copy Markdown
Member

Fixes #[insert GH or internal issue link(s)].

When --show-diff is passed, the command fetches the currently deployed trigger configuration from the remote worker and displays a colored diff against the local configuration. This covers routes, custom domains, cron schedules, and the workers_dev/preview_urls subdomain settings.

The flag also works with --dry-run to preview what trigger changes would be applied without actually deploying.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • 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 29, 2026

🦋 Changeset detected

Latest commit: 58c0123

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

This PR includes changesets to release 4 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch
@cloudflare/wrangler-bundler Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

✅ All changesets look good

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 adds a --show-diff flag to wrangler triggers deploy that fetches the remote trigger config and diffs it against the local config, supporting both standalone and --dry-run modes.

Issues

  1. Deployment timing inflated by --show-diff network calls — When --show-diff is used without --dry-run, the fetchRemoteTriggers call (6 API requests via fetchWorkerConfig) runs between start = Date.now() and uploadMs = Date.now() - start, inflating the reported deployment time.

  2. fetchWorkerConfig makes 6 API requests but only 4 are usedfetchRemoteTriggers calls fetchWorkerConfig which fetches bindings and service environment metadata in addition to the 4 things actually used (routes, custom domains, subdomain status, cron triggers). This adds unnecessary latency and API load every time --show-diff is used. Consider either adding a lighter-weight fetch function or documenting why the reuse is acceptable.

return;
}

const uploadMs = Date.now() - start;
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.

uploadMs now includes the time spent in fetchRemoteTriggers (which makes 6 API calls via fetchWorkerConfig), inflating the reported deployment timing when --show-diff is used.

Move the start capture below the diff fetch, or capture the time just before the actual deployments begin:

Suggested change
const uploadMs = Date.now() - start;
const deployStart = Date.now();

And then compute deployMs later as Date.now() - deployStart - uploadMs accordingly — or simpler, just move the snapshot fetch before start.

Comment on lines +104 to +110
if (props.showDiff) {
remoteTriggersSnapshot = await fetchRemoteTriggers(
accountId,
scriptName,
envName
);
}
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.

fetchWorkerConfig makes 6 parallel API requests (bindings, routes, custom domains, subdomain, service env metadata, cron triggers), but fetchRemoteTriggers only uses 4 of those results. The wasted bindings + service-env-metadata fetches add latency and unnecessary API traffic.

Consider adding a targeted fetch function (e.g. fetchWorkerTriggerConfig) that only requests the 4 endpoints needed, or at minimum add a comment explaining the trade-off.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 29, 2026

I've posted my review on PR #14114. Here's a summary of the two issues I flagged:

  1. Deployment timing inflated by --show-diff network calls — The fetchRemoteTriggers call (which makes 6 API requests) runs between the start timestamp and the uploadMs = Date.now() - start calculation at deploy.ts:128, inflating the reported deployment time when --show-diff is used without --dry-run. I suggested moving the start capture or restructuring to exclude the diff-fetch time.

  2. fetchWorkerConfig fetches more data than neededfetchRemoteTriggers calls fetchWorkerConfig which makes 6 parallel API requests, but only 4 of the results (routes, custom domains, subdomain status, cron triggers) are actually used. The bindings and service environment metadata fetches add unnecessary latency and API load. I suggested either creating a lighter-weight fetch function or documenting the trade-off.

github run

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 29, 2026

create-cloudflare

npm i https://pkg.pr.new/cloudflare/workers-sdk/create-cloudflare@14114

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/deploy-helpers@14114

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/kv-asset-handler@14114

miniflare

npm i https://pkg.pr.new/cloudflare/workers-sdk/miniflare@14114

@cloudflare/pages-shared

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/pages-shared@14114

@cloudflare/unenv-preset

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/unenv-preset@14114

@cloudflare/vite-plugin

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/vite-plugin@14114

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

npm i https://pkg.pr.new/cloudflare/workers-sdk/wrangler@14114

@cloudflare/wrangler-bundler

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/wrangler-bundler@14114

commit: 58c0123

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