Skip to content

fix(cli): instrument new Cloudflare workers and harden the Wrangler flow - #2563

Open
sentry-junior[bot] wants to merge 1 commit into
feat/cli-wizard-sourcemaps-cloudflarefrom
feat/cli-wizard-sourcemaps-cloudflare-fixes
Open

sentry-junior[bot] wants to merge 1 commit into
feat/cli-wizard-sourcemaps-cloudflarefrom
feat/cli-wizard-sourcemaps-cloudflare-fixes

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Stacked on #2529. These fixes address Warden and Bugbot findings on that PR, and each one changes behaviour that sentry-wizard 9.1.0 shipped, so they're kept apart from the port. The fixes that keep upstream behaviour are on #2529 itself.

Behaviour changes against sentry-wizard 9.1.0

  • Cloudflare, missing main file (SHJ-RG7): when Wrangler's main points to a file that doesn't exist, the wizard creates the starter worker there and wraps it. Upstream skipped setup silently and still reported success.
  • Cloudflare, no main (YBF-MLA): the starter worker written to src/index.ts is now wrapped with Sentry.withSentry(). Upstream wrote a plain worker with no Sentry.
  • Cloudflare, existing src/index.ts with no main: the existing file is wrapped instead of being overwritten by the starter worker.
  • Cloudflare, wrangler.toml (WHX-UYU): the copy-paste snippet includes main = "src/index.ts" when the wizard sets main. Upstream left it out.
  • webpack, non-array plugins (UNB-FTW): plugins: existingPlugins or plugins: getPlugins() becomes [...existingPlugins, sentryWebpackPlugin(…)]. Upstream replaced the value and dropped those plugins. undefined and null are still replaced.
  • Wrangler, existing post<deploy> (5YD-7F8): an existing post<deploy> script is kept, with && <pm> sentry:sourcemaps added after it. Upstream overwrote it. It's left alone when it already runs sentry:sourcemaps.
  • Wrangler, Yarn 2+ (RP5-3PG): Yarn Berry doesn't run post scripts, so the upload is chained onto the deploy script (&& yarn sentry:sourcemaps). npm, pnpm, Yarn 1 and Bun keep the post<deploy> hook.
  • Wrangler, no deploy script (5WP-827): the wizard still writes sentry:sourcemaps, the .sentryclirc upload target and the auth token, then shows the deploy command to add. Upstream stopped before writing any of them and still reported success.
  • Wrangler, wrapped commands (HJA-K3Y): deploy scripts that run wrangler deploy through npx (including -y and wrangler@<version>), pnpx, bunx, pnpm / pnpm exec / pnpm dlx, yarn, bun x, cross-env, or a leading VAR=value are now edited. Upstream accepted only a bare wrangler deploy.
  • Wrangler, manual fallback: when the wizard can't edit the deploy script, it shows wrangler deploy with the --outdir, --var SENTRY_RELEASE:… and --upload-source-maps flags. Upstream showed the unchanged script.
  • Source maps, framework redirect (YSZ-BFQ): the SvelteKit and React Native redirect is offered only when this CLI version has that wizard. Without it, the wizard shows the framework's guides and asks whether to continue or exit, instead of throwing ValidationError once the redirect is accepted. SvelteKit shows up again on its own once its runner lands.

Product calls

  • Wrapping with withSentry: follows the Wrangler install guide and the existing wrap path for configured entry points.
  • post<deploy> hook, merged rather than overwritten: the Wrangler source maps guide uses a postdeploy hook, so that stays the default. An existing hook is kept, the way the other flows keep user scripts.
  • && chaining for Yarn 2+ only: matches how the sentry-cli flow attaches sentry:sourcemaps to the build script. Other package managers keep the hook from the docs.
  • Warn, not fail, with no deploy script: matches the sentry-cli flow, which writes the script and config and then shows what to add by hand.
  • Wrapped npx / pnpm exec deploy commands: the new flags go after the wrangler deploy segment, as they do for a bare command.

via @BYK.

--

View Session [Sentry]

Changes how the ported source maps and Cloudflare wizards behave where
sentry-wizard 9.1.0 left a project half set up:

- Cloudflare: create a missing entry point where Wrangler's `main` points,
  and wrap new and existing workers with `Sentry.withSentry()`
- Cloudflare: show `main` in the wrangler.toml snippet when it is added
- webpack: keep a non-array `plugins` value by spreading it
- Wrangler: keep an existing `post<deploy>` script, chain the upload onto
  the deploy script for Yarn 2+, and still set up the upload script and
  CLI config when no deploy script is picked
- Wrangler: edit deploy scripts that run wrangler through npx, pnpm exec,
  yarn, bunx, or cross-env, and show the flags to add when it can't
- Source maps: offer the SvelteKit or React Native wizard only when this
  version has it
@sentry-junior
sentry-junior Bot requested a review from BYK November 27, 2026 17:14
@sentry-junior
sentry-junior Bot added this pull request to stack #2564 November 27, 2026 17:14
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 27, 2026 5:14pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 27, 2026 5:14pm UTC

Request Review

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 347f342. Configure here.

clack.log.success(`Created ${chalk.cyan(defaultEntryPoint)}.`);

return;
clack.log.success(`Created ${chalk.cyan(entryPoint)}.`);

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.

TS starter written to non-TS paths

Medium Severity

When Wrangler main points at a missing file, the wizard now writes getCloudflareWorkerTemplateWithHandler() to that path. That template is TypeScript (satisfies, type annotations) regardless of extension, so a missing .js or .mjs entry becomes invalid JavaScript and Wrangler cannot bundle it.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 347f342. Configure here.

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — 347f3420 Deployed Nov 27, 2026 by vercel[bot]
Preview – sentry-local — 347f3420 Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant