Repository navigation
fix(cli): instrument new Cloudflare workers and harden the Wrangler flow - #2563
Open
sentry-junior[bot] wants to merge 13 commits into
Open
sentry-junior[bot] wants to merge 13 commits into
sentry-junior[bot] wants to merge 13 commits into
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
The starter worker had TypeScript annotations whatever the entry point's extension, so a missing `.js` or `.mjs` `main` got a worker Wrangler couldn't bundle. Leave the annotations out unless the entry point is a TypeScript file. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
The flags went to the first text match of the deploy command, so an earlier command such as `echo Running wrangler deploy` got them instead of the real `wrangler deploy`. Insert them at the deploy command's own offset in the script. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…zard-sourcemaps-cloudflare-fixes
The deploy-script rewrite checked for an existing `--outdir` and `--upload-source-maps`, but always appended `--var SENTRY_RELEASE:…`, so each rerun stacked another one. Skip it when the script already sets SENTRY_RELEASE, and leave the script alone when nothing is missing.
The Cloudflare wizard set `compatibility_date` to today, overwriting the user's date and with it the Worker's runtime behaviour. Set it only when the Wrangler config doesn't have one, and say so in the TOML snippet.
…deploy Any `deploy` after `wrangler` counted as a Workers deploy, so `wrangler pages deploy` and `wrangler versions deploy`, bare or run through a runner such as `npx`, got the Workers-only `--outdir`, `--upload-source-maps` and `--var` flags, which break those commands. Skip them, so the wizard shows the manual instructions instead.
The rerun guard only knew `SENTRY_RELEASE:` without quotes, so `--var SENTRY_RELEASE=…` or a quoted binding still got a second `--var SENTRY_RELEASE:…`. Match `=` or `:` and optional quotes, the way the Spotlight `--var` check in `lib/wrangler.ts` does.
Any dash flag before `wrangler` counted as a runner arg, so in `pnpm -C wrangler deploy`, `pnpm --filter wrangler deploy` or `yarn --cwd wrangler deploy` the directory or package name `wrangler` was taken for the CLI and the package's `deploy` script got Workers flags. Skip the value of runner flags that take one.
BYK
approved these changes
Nov 27, 2026
The value flags were one list for every runner, so `pnpm -w` and `yarn -p`, which take no value, skipped the `wrangler` after them and the deploy script wasn't recognized. Key the list by runner: `-p` and `-w` take a value only for npx.
…zard-sourcemaps-cloudflare-fixes
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 698999a. Configure here.
The runner's value flags came from the first arg only, so after `cross-env` or a leading `FOO=1` none applied, and in `cross-env … yarn --cwd wrangler deploy` the directory was taken for the CLI. Pick up the runner wherever it appears before `wrangler`.
Each bot round on the runner parser found another shell form it got wrong. Edit only bare `wrangler deploy` and `npx`, `pnpm`, `yarn` or `bunx` right before `wrangler deploy`. Runner flags, `cross-env`, `FOO=1`, `pnpm exec`/`dlx`, `bun x` and `wrangler@<version>` now get the manual instructions, and the env-prefix and value-flag handling goes.
This branch is pending to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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
mainfile (SHJ-RG7): when Wrangler'smainpoints 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.main(YBF-MLA): the starter worker written tosrc/index.tsis now wrapped withSentry.withSentry(). Upstream wrote a plain worker with no Sentry.src/index.tswith nomain: the existing file is wrapped instead of being overwritten by the starter worker.wrangler.toml(WHX-UYU): the copy-paste snippet includesmain = "src/index.ts"when the wizard setsmain. Upstream left it out.plugins(UNB-FTW):plugins: existingPluginsorplugins: getPlugins()becomes[...existingPlugins, sentryWebpackPlugin(…)]. Upstream replaced the value and dropped those plugins.undefinedandnullare still replaced.post<deploy>(5YD-7F8): an existingpost<deploy>script is kept, with&& <pm> sentry:sourcemapsadded after it. Upstream overwrote it. It's left alone when it already runssentry:sourcemaps.postscripts, so the upload is chained onto the deploy script (&& yarn sentry:sourcemaps). npm, pnpm, Yarn 1 and Bun keep thepost<deploy>hook.sentry:sourcemaps, the.sentryclircupload target and the auth token, then shows the deploy command to add. Upstream stopped before writing any of them and still reported success.wrangler deploythroughnpx(including-yandwrangler@<version>),pnpx,bunx,pnpm/pnpm exec/pnpm dlx,yarn,bun x,cross-env, or a leadingVAR=valueare now edited. Upstream accepted only a barewrangler deploy.wrangler deploywith the--outdir,--var SENTRY_RELEASE:…and--upload-source-mapsflags. Upstream showed the unchanged script.ValidationErroronce the redirect is accepted. SvelteKit shows up again on its own once its runner lands..jsor.mjsmain: the starter worker written there is plain JavaScript. Only TypeScript entry points get the typed starter.wrangler deploycommand, not on earlier text that matches it, such asecho Running wrangler deploy. Upstream edited the first match.SENTRY_RELEASEdoesn't get a second--var SENTRY_RELEASE:…. Upstream added one on every run.compatibility_date: the Worker's date is kept, and today's date is only added when the config has none. The TOML snippet marks it "only if not set yet". Upstream always overwrote it with today's date.pages deployandversions deploy: these aren't treated as a Workers deploy, bare or through a runner, so they don't get the Workers-only flags that would break them. The wizard shows the manual instructions instead. Upstream edited a barewrangler pages deployorwrangler versions deploy.Product calls
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 apostdeployhook, 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 attachessentry:sourcemapsto the build script. Other package managers keep the hook from the docs.npx/pnpm execdeploy commands: the new flags go after thewrangler deploysegment, as they do for a bare command.via @BYK.
--
View Session [Sentry]