Title: @sentry/astro: Use the Cloudflare Vite plugin for Workers builds · Issue #25344 · getsentry/sentry-javascript · GitHub
Open Graph Title: @sentry/astro: Use the Cloudflare Vite plugin for Workers builds · Issue #25344 · getsentry/sentry-javascript
X Title: @sentry/astro: Use the Cloudflare Vite plugin for Workers builds · Issue #25344 · getsentry/sentry-javascript
Description: On Cloudflare Workers, an Astro app still needs a hand-written sentry.server.config.js that is also the wrangler main: // sentry.server.config.js import * as Sentry from '@sentry/cloudflare'; import handler from '@astrojs/cloudflare/entr...
Open Graph Description: On Cloudflare Workers, an Astro app still needs a hand-written sentry.server.config.js that is also the wrangler main: // sentry.server.config.js import * as Sentry from '@sentry/cloudflare'; impor...
X Description: On Cloudflare Workers, an Astro app still needs a hand-written sentry.server.config.js that is also the wrangler main: // sentry.server.config.js import * as Sentry from '@sentry/cloudflare'...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25344
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@sentry/astro: Use the Cloudflare Vite plugin for Workers builds","articleBody":"On Cloudflare Workers, an Astro app still needs a hand-written `sentry.server.config.js` that is also the wrangler `main`:\n\n```js\n// sentry.server.config.js\nimport * as Sentry from '@sentry/cloudflare';\nimport handler from '@astrojs/cloudflare/entrypoints/server';\nexport default Sentry.withSentry(env => ({ dsn: env.E2E_TEST_DSN /* ... */ }), handler);\n```\n\n```jsonc\n// wrangler.jsonc\n{ \"main\": \"./sentry.server.config.js\" }\n```\n\nThe goal is the setup that `@sentry/cloudflare/vite` gives other frameworks: wrangler `main` stays the package entry, and the options live in an `instrument.server.*` file beside the wrangler config.\n\n```jsonc\n// wrangler.jsonc\n{ \"main\": \"@astrojs/cloudflare/entrypoints/server\" }\n```\n\n```js\n// instrument.server.js\nimport { defineCloudflareOptions } from '@sentry/cloudflare';\nexport default defineCloudflareOptions(env => ({ dsn: env.E2E_TEST_DSN /* ... */ }));\n```\n\n`@sentry/cloudflare/vite` will be able to wrap a package-specifier `main` as of getsentry/sentry-javascript#24522. The rest of the work is in `@sentry/astro`.\n\n## What blocks it\n\nI tried this setup in the `astro-6-cf-workers` e2e app, with `sentryCloudflareVitePlugin()` added to `vite.plugins` in `astro.config.mjs`. The Cloudflare plugin wrapped the entry, but 9 of 11 tests failed with `Sentry Logger [error]: Transport disabled`.\n\n1. **Default server init with no DSN.** With no `sentry.server.config.*` file, the integration falls back to `buildServerSnippet()` (`packages/astro/src/integration/snippets.ts`). It injects `Sentry.init({ dsn: import.meta.env.PUBLIC_SENTRY_DSN, ... })` into every SSR page through `injectScript('page-ssr', ...)`. In this app that builds as `dsn: void 0`, and this init disables the transport.\n2. **The integration does not add the Cloudflare plugin.** For Workers builds, `packages/astro/src/integration/index.ts` adds its own `sentryCloudflareVitePlugin()` from `./cloudflare`. That plugin wraps `astrojs-ssr-virtual-entry`, which `@astrojs/cloudflare` v13 no longer has, and it always passes `() => undefined` as the options. The user must add `@sentry/cloudflare/vite` by hand.\n3. **Two orchestrion plugins.** The integration adds `sentryOrchestrionPlugin()` for Workers, and `@sentry/cloudflare/vite` adds another one (with the workerd-safe `dcModule`). With both, the build-time instrumentation runs twice.\n\n## Proposed fix\n\n* For Cloudflare Workers builds, add `sentryCloudflareVitePlugin()` from `@sentry/cloudflare/vite` in place of the integration's own Cloudflare and orchestrion plugins.\n* Do not inject the default server init snippet on Workers. The `withSentry` wrap does the init from `instrument.server.*`, or from `env` when there is no such file.\n* Keep `sentry.server.config.*` working for apps that still use it as `main`, because the auto-instrument plugin leaves an entry that is already wrapped alone.\n* Update `astro-6-cf-workers` (and `astro-5-cf-workers` if it applies): remove `sentry.server.config.js`, add `instrument.server.js` with `defineCloudflareOptions`, and set `main` to `@astrojs/cloudflare/entrypoints/server`.\n\n## Notes\n\n* `@astrojs/cloudflare` v13 sets `main` to `@astrojs/cloudflare/entrypoints/server` when the wrangler config has none (`cloudflareConfigCustomizer` in its `dist/wrangler.js`).\n* Its `server.js` ends with `export { server_default as default }`. getsentry/sentry-javascript#24522 adds support for that export form to the auto-instrument transform.\n* Check `astro dev` too: the integration only adds its Workers plugin when `command !== 'dev'`, and `@sentry/cloudflare/vite` instruments `vite dev` as well.","author":{"url":"https://github.com/isaacs","@type":"Person","name":"isaacs"},"datePublished":"2026-10-14T02:53:59Z","url":"https://github.com/getsentry/sentry-javascript/issues/25344"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:70510ac4-4e56-d854-174e-a0dcc10aeda6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BFB6:21A483:1121738:16E6667:6B041583 |
| html-safe-nonce | 5b6895b868e7b8c98b2b82da2a96da6567d49b4559a2bdb259e088fb928c4494 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkI2OjIxQTQ4MzoxMTIxNzM4OjE2RTY2Njc6NkIwNDE1ODMiLCJ2aXNpdG9yX2lkIjoiNTI3NzEzNzYwMTU0NjE2MzU4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7d2275e2eac32bbecdd344b796f6247c1c730ba6380394dd12c3ea6475f2af75 |
| hovercard-subject-tag | issue:5841113717 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/25344/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2f2bb0be4699a6d24d1f99ee93b6c54dbab90f968a8a7c23774618f587b3bd18/getsentry/sentry-javascript/issues/25344 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2f2bb0be4699a6d24d1f99ee93b6c54dbab90f968a8a7c23774618f587b3bd18/getsentry/sentry-javascript/issues/25344 |
| og:image:alt | On Cloudflare Workers, an Astro app still needs a hand-written sentry.server.config.js that is also the wrangler main: // sentry.server.config.js import * as Sentry from '@sentry/cloudflare'; impor... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | isaacs |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width