Title: @sentry/astro: Cloudflare Worker server wrap not applied with @astrojs/cloudflare v14 (transform targets `astrojs-ssr-virtual-entry`, adapter now emits `virtual:cloudflare/worker-entry`) · Issue #21901 · getsentry/sentry-javascript · GitHub
Open Graph Title: @sentry/astro: Cloudflare Worker server wrap not applied with @astrojs/cloudflare v14 (transform targets `astrojs-ssr-virtual-entry`, adapter now emits `virtual:cloudflare/worker-entry`) · Issue #21901 · getsentry/sentry-javascript
X Title: @sentry/astro: Cloudflare Worker server wrap not applied with @astrojs/cloudflare v14 (transform targets `astrojs-ssr-virtual-entry`, adapter now emits `virtual:cloudflare/worker-entry`) · Issue #21901 · getsentry/sentry-javascript
Description: Summary With @astrojs/cloudflare v14, @sentry/astro's server-side init is never applied to the deployed Cloudflare Worker. The Worker's default export is left un-wrapped by withSentry, so server-side error/log capture does not initialize...
Open Graph Description: Summary With @astrojs/cloudflare v14, @sentry/astro's server-side init is never applied to the deployed Cloudflare Worker. The Worker's default export is left un-wrapped by withSentry, so server-si...
X Description: Summary With @astrojs/cloudflare v14, @sentry/astro's server-side init is never applied to the deployed Cloudflare Worker. The Worker's default export is left un-wrapped by withSentry, so s...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/21901
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@sentry/astro: Cloudflare Worker server wrap not applied with @astrojs/cloudflare v14 (transform targets `astrojs-ssr-virtual-entry`, adapter now emits `virtual:cloudflare/worker-entry`)","articleBody":"## Summary\n\nWith `@astrojs/cloudflare` v14, `@sentry/astro`'s server-side init is never applied to the deployed Cloudflare Worker. The Worker's default export is left un-wrapped by `withSentry`, so server-side error/log capture does not initialize at the fetch boundary — server-side Sentry silently does nothing.\n\n## Versions\n\n- `@sentry/astro` 10.62.0\n- `@sentry/cloudflare` 10.62.0\n- `@astrojs/cloudflare` 14.0.1\n- `astro` 7.0.3\n- `output: 'server'`, Cloudflare **Workers** (not Pages)\n\n## Root cause\n\n`sentryCloudflareVitePlugin` (`packages/astro/src/integration/cloudflare.ts`) wraps the Worker by transforming the module whose id contains `astrojs-ssr-virtual-entry`:\n\n```js\ntransform(code, id) {\n if (!id.includes(\"astrojs-ssr-virtual-entry\")) {\n return undefined;\n }\n // ...rewrites `export default X;` -> `export default withSentry(() => undefined, X);`\n}\n```\n\n`@astrojs/cloudflare` v14 builds the Worker through `@cloudflare/vite-plugin`, whose entry virtual module id is `virtual:cloudflare/worker-entry` (its generated body ends with `export default mod.default ?? {};`). The old `astrojs-ssr-virtual-entry` id is no longer produced, so the `transform` guard always returns early and the entry is never wrapped.\n\n## Effect\n\nWith an app configured per the [Astro + Cloudflare docs](https://docs.sentry.io/platforms/javascript/guides/cloudflare/frameworks/astro/) (the `sentry()` integration in `astro.config` plus a `sentry.server.config.ts` doing `export default Sentry.withSentry((env) => ({ ... }), handler)`), the generated `dist/server/entry.mjs` default export is the **raw** Astro handler. Grepping all of `dist/server` for `withSentry(() =>` finds no match — the plugin's wrap never ran.\n\nThe only remaining server wiring is the injected `import \"sentry.server.config.(ts|js)\"` (`injectScript(\"page-ssr\", ...)`). That runs lazily during a page render, so it doesn't deterministically instrument the Worker's fetch entry:\n\n- errors on the first request (before any page module has evaluated the config) aren't captured;\n- routes that don't pull the page-ssr module graph (e.g. API endpoints) aren't covered;\n- for a Worker whose first traffic is an API route, `Sentry.init` may never run at all.\n\n## Repro\n\n1. Scaffold an Astro app with `output: 'server'` and the `@astrojs/cloudflare` v14 adapter (Workers, not Pages).\n2. `npm i @sentry/astro @sentry/cloudflare`; add `sentry()` to `integrations`; create `sentry.server.config.ts` per the docs:\n ```ts\n import * as Sentry from '@sentry/cloudflare'\n import handler from '@astrojs/cloudflare/entrypoints/server'\n export default Sentry.withSentry((env) => ({ dsn: env.SENTRY_DSN, enableLogs: true }), handler)\n ```\n3. `astro build`.\n4. Inspect `dist/server/entry.mjs`: the default export is the un-wrapped Astro handler, and `grep -r \"withSentry(() =>\" dist/server` returns nothing.\n\n## Suggested fix\n\nHave `sentryCloudflareVitePlugin`'s `transform` also match the `@cloudflare/vite-plugin` entry id `virtual:cloudflare/worker-entry` (whose default-export expression is `mod.default ?? {}`), in addition to `astrojs-ssr-virtual-entry`, so the wrap applies on `@astrojs/cloudflare` v14+.\n\n## Workaround\n\nFor anyone hitting this before a fix lands: a tiny build-only Vite plugin that transforms the `virtual:cloudflare/worker-entry` module and wraps its `export default mod.default ?? {};` with your own `withSentry(optionsCallback, handler)` restores deterministic, eager wrapping of the Worker entry.\n","author":{"url":"https://github.com/0x80","@type":"Person","name":"0x80"},"datePublished":"2026-07-01T15:52:33Z","url":"https://github.com/getsentry/sentry-javascript/issues/21901"}
| 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:6195f15f-1b40-1dd4-710e-fae48cbe11f0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C2BC:1DA36E:27FE1AD:344DE00:6B0429E0 |
| html-safe-nonce | 8e2e91fcb8507e788b170bdc6a0fae8f9f1dba3b6efd245749df4f6da2d7c28b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkJDOjFEQTM2RToyN0ZFMUFEOjM0NERFMDA6NkIwNDI5RTAiLCJ2aXNpdG9yX2lkIjoiNzI4NjM4NDU5MTc5ODI4MjcyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b53ae5fa8b135b0b3519194030ebeb0cc0f8b8e7b5fd4ab957702b8bc0c8ecf8 |
| hovercard-subject-tag | issue:4787127323 |
| 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/21901/issue_layout |
| twitter:image | https://opengraph.githubassets.com/05b95d5dc2b9be0dc8f2600b8d37779057b01fe10558d31516c8ee8c020f708d/getsentry/sentry-javascript/issues/21901 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/05b95d5dc2b9be0dc8f2600b8d37779057b01fe10558d31516c8ee8c020f708d/getsentry/sentry-javascript/issues/21901 |
| og:image:alt | Summary With @astrojs/cloudflare v14, @sentry/astro's server-side init is never applied to the deployed Cloudflare Worker. The Worker's default export is left un-wrapped by withSentry, so server-si... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 0x80 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| 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 | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | canary-1 |
| 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