Skip to content

Conversation

@JPeer264
Copy link
Member

(closes #1155)
(closes WIZARD-115)

This adds support for the Wizard to automatically wrap the default export of the Cloudflare Workers with Sentry.withSentry.

As of now no support for e.g. logging has been added (so the template stayed the same as the printed one from before).

The traceStep "Update Wrangler config with Sentry requirements" has moved down, as it will create a default entry file automatically if there is none, and will then update the wrangler.jsonc with the correct main file in case that was not given just yet. This is actually an edge case but a possibility.

@JPeer264 JPeer264 self-assigned this Dec 23, 2025
@linear
Copy link

linear bot commented Dec 23, 2025

@github-actions
Copy link

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- Support wrapping workers main file ([#1156](https://github.com/getsentry/sentry-wizard/pull/1156))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 1ec5286

Copy link
Member

@s1gr1d s1gr1d left a comment

Choose a reason for hiding this comment

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

Nice addition and good tests! Did you try the CLI locally in an actual project as well?

@JPeer264
Copy link
Member Author

JPeer264 commented Jan 5, 2026

Nice addition and good tests! Did you try the CLI locally in an actual project as well?

Surely, with couple of npm create cloudflare@latest projects

Comment on lines +99 to +104
);
} catch (e) {
clack.log.warn(
'Could not automatically set up Sentry initialization. Please set it up manually using instructions from https://docs.sentry.io/platforms/javascript/guides/cloudflare/',
);
debug(e);

This comment was marked as outdated.

@JPeer264 JPeer264 force-pushed the jp/cloudflare-wizard-workers branch from 4e2a379 to 29656bd Compare January 8, 2026 07:54
@JPeer264 JPeer264 enabled auto-merge (squash) January 8, 2026 07:55
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Cloudflare

  • Support wrapping workers main file by JPeer264 in #1156
  • Enable update of the wrangler file by JPeer264 in #1149
  • Add a basic skeleton for cloudflare by JPeer264 in #1147

Mcp

  • Add multi-select support for MCP configuration by cursor in #1153
  • Add OpenCode as MCP server provider option by codyde in #1154

Bug Fixes 🐛

  • (next) Remove Turbopack outro warning by logaretm in #1173
  • (react-router) Avoid force-running npx react-router reveal by Lms24 in #1181

Build / dependencies / internal 🔧

Deps

  • Update tmp from 0.0.33 to 0.2.4 by Lms24 in #1176
  • Update brace-expansion to 2.0.2 and 1.1.12 by Lms24 in #1175
  • Bump js-yaml from 4.1.0 to 4.1.1 by dependabot in #1114
  • Bump vite from 6.3.6 to 6.4.1 in /e2e-tests/test-applications/cloudflare-wrangler-sourcemaps-test-app by dependabot in #1112
  • Bump devalue from 4.3.3 to 5.6.1 in /e2e-tests/test-applications/cloudflare-wrangler-sourcemaps-test-app by dependabot in #1172

Test

  • Clean up e2e test utils by Lms24 in #1182
  • Update vite to 7.3.0 in pnpm-workspace-test-app by Lms24 in #1174
  • Unstale lock file in pnpm-workspace-test-app by Lms24 in #1170
  • Update @vitest/coverage-v8 to bump glob to 10.5.0 by Lms24 in #1169
  • Update @angular/common and related dependencies by Lms24 in #1168
  • Update @cloudflare/vitest-pool-workers dependencies by Lms24 in #1167

Other

  • (publish) Use fully automatic changelog generation by Lms24 in #1138
  • Remove duplications for SDKs that do not support spotlight by JPeer264 in #1151
  • Wrong changelog category for last update by JPeer264 in #1150

Other

  • test(e2e): Migrate React-native and Expo e2e tests to use clifty by Lms24 in #1179
  • test(e2e): Migrate Flutter e2e tests to use clifty by Lms24 in #1180
  • test(e2e): Migrate Nuxt e2e tests to use clifty by Lms24 in #1178
  • test(e2e): Migrate Angular e2e tests to clifty by Lms24 in #1165

🤖 This preview updates automatically when you update the PR.

Comment on lines +52 to +55
const entryPointPath = path.join(process.cwd(), entryPointFromConfig);

if (fs.existsSync(entryPointPath)) {
clack.log.info(
Copy link

Choose a reason for hiding this comment

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

Bug: For new projects, the wizard creates a wrangler.jsonc pointing to a non-existent entry point, then createSentryInitFile silently fails, leaving the project in a broken state.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

In a fresh project without a wrangler.jsonc, the wizard first calls ensureWranglerConfig(), which creates a config file pointing to a non-existent entry point like src/index.ts. Subsequently, createSentryInitFile() is called. It reads this entry point, but because the file doesn't exist (fs.existsSync() returns false), the function silently returns without creating the necessary Sentry initialization file. The wizard completes successfully, but the wrangler.jsonc remains pointing to a non-existent file, causing subsequent wrangler deploy commands to fail.

💡 Suggested Fix

The createSentryInitFile function should handle the case where the entry point file does not exist. Instead of silently returning, it should create the entry point file with the Sentry wrapper. This ensures the file pointed to by wrangler.jsonc actually exists and is correctly configured.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/cloudflare/sdk-setup.ts#L52-L55

Potential issue: In a fresh project without a `wrangler.jsonc`, the wizard first calls
`ensureWranglerConfig()`, which creates a config file pointing to a non-existent entry
point like `src/index.ts`. Subsequently, `createSentryInitFile()` is called. It reads
this entry point, but because the file doesn't exist (`fs.existsSync()` returns false),
the function silently returns without creating the necessary Sentry initialization file.
The wizard completes successfully, but the `wrangler.jsonc` remains pointing to a
non-existent file, causing subsequent `wrangler deploy` commands to fail.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8325139

@JPeer264 JPeer264 merged commit 5e00002 into master Jan 8, 2026
53 checks passed
@JPeer264 JPeer264 deleted the jp/cloudflare-wizard-workers branch January 8, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloudflare update workers default export

3 participants