Title: fix(tanstackstart-react): workerd/worker export conditions resolve to @sentry/node, breaking Cloudflare Workers · Issue #20038 · getsentry/sentry-javascript · GitHub
Open Graph Title: fix(tanstackstart-react): workerd/worker export conditions resolve to @sentry/node, breaking Cloudflare Workers · Issue #20038 · getsentry/sentry-javascript
X Title: fix(tanstackstart-react): workerd/worker export conditions resolve to @sentry/node, breaking Cloudflare Workers · Issue #20038 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues How do you use Sentry? Sentry SaaS (sentry.io) Which SDK are you using? @sentry/tanstackstart-react SDK Version...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues How do you use Sentry? Sentry SaaS (sentry.io) Which SDK are you using?...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues How do you use Sentry? Sentry SaaS (sentry.io) Which SDK are you using?...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/20038
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix(tanstackstart-react): workerd/worker export conditions resolve to @sentry/node, breaking Cloudflare Workers","articleBody":"### Is there an existing issue for this?\n\n- [X] I have checked for existing issues [https://github.com/getsentry/sentry-javascript/issues](\u003chttps://github.com/getsentry/sentry-javascript/issues>)\n\n### How do you use Sentry?\n\nSentry SaaS ([sentry.io](\u003chttp://sentry.io>))\n\n### Which SDK are you using?\n\n`@sentry/tanstackstart-react`\n\n### SDK Version\n\n10.46.0\n\n### Framework Version\n\nTanStack Start \\~1.166 (React 19, SSR via Nitro \\~3.0)\n\n### Link to Sentry event\n\n*No response*\n\n### Reproduction Example/SDK Setup\n\nThe core claim — that the `workerd`/`worker` conditions resolve to a file that re-exports `@sentry/node` — is verifiable directly from the package metadata and source without any app:\n\n1. Inspect [`packages/tanstackstart-react/package.json`](\u003chttps://github.com/getsentry/sentry-javascript/blob/10.46.0/packages/tanstackstart-react/package.json>) — `workerd`, `worker`, and `node` all resolve to `index.server.js`\n2. Inspect [`build/esm/index.server.js`](\u003chttps://github.com/getsentry/sentry-javascript/blob/10.46.0/packages/tanstackstart-react/src/server/index.ts>) — does `export * from '@sentry/node'`\n\nFor the runtime failure:\n\n1. Create a TanStack Start app deployed to Cloudflare Workers (Nitro `cloudflare-module` preset, `noExternals: true`)\n2. Install `@sentry/tanstackstart-react@10.46.0`\n3. Import in `router.tsx` (SSR entry): `import * as Sentry from '@sentry/tanstackstart-react'`\n4. Set `ssr.resolve.conditions: ['workerd', 'worker', 'browser', 'import', 'module', 'default']` in Vite config\n5. Build and deploy — the Worker returns HTTP 500 with `\"Cannot initialize ExportedHandler\"`\n\nBecause Nitro uses `noExternals: true` for Workers (no `node_modules` at runtime), the package is **not** externalized. Vite resolves it using `ssr.resolve.conditions` (not `ssr.resolve.externalConditions`), so the `workerd` condition takes effect and routes to `index.server.js`.\n\n### Steps to Reproduce\n\n`@sentry/tanstackstart-react` advertises `workerd` and `worker` export conditions in its `package.json`, suggesting compatibility with Cloudflare Workers and similar edge runtimes. However, **all three server-side conditions (**`workerd`, `worker`, `node`) resolve to the exact same file — `index.server.js` — which re-exports `@sentry/node`.\n\nThe Node-orientation is not limited to the barrel re-export. The server source modules themselves import directly from `@sentry/node`:\n\n* [`src/server/index.ts`](\u003chttps://github.com/getsentry/sentry-javascript/blob/10.46.0/packages/tanstackstart-react/src/server/index.ts>) — re-exports from `@sentry/node`\n* [`src/server/sdk.ts`](\u003chttps://github.com/getsentry/sentry-javascript/blob/10.46.0/packages/tanstackstart-react/src/server/sdk.ts>) — imports `@sentry/node` for `init`\n* [`src/server/wrapFetchWithSentry.ts`](\u003chttps://github.com/getsentry/sentry-javascript/blob/10.46.0/packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts>) — imports from `@sentry/node`\n* [`src/server/middleware.ts`](\u003chttps://github.com/getsentry/sentry-javascript/blob/10.46.0/packages/tanstackstart-react/src/server/middleware.ts>) — imports from `@sentry/node`\n\nWhen bundled for Workers (where `@sentry/tanstackstart-react` is non-externalized and resolved under the `workerd` condition), this pulls the `@sentry/node` dependency tree — including `@opentelemetry/instrumentation-undici` and transitive `node:*` built-in imports — into the Worker bundle. While Cloudflare Workers with `nodejs_compat` do support many Node APIs to varying degrees, in our deployment this caused module evaluation failure: the Worker's default export became `null`, producing `\"Cannot initialize ExportedHandler\"` at runtime with no stack trace. The exact failure mechanism likely depends on which `node:*` shims are partial or missing for the given compatibility date, but the root issue is that Workers resolves to a Node SDK entry that was never designed for this runtime.\n\n`package.json` exports (v10.46.0):\n\n```json\n{\n \"exports\": {\n \".\": {\n \"workerd\": {\n \"import\": \"./build/esm/index.server.js\",\n \"require\": \"./build/cjs/index.server.js\"\n },\n \"worker\": {\n \"import\": \"./build/esm/index.server.js\",\n \"require\": \"./build/cjs/index.server.js\"\n },\n \"browser\": {\n \"import\": \"./build/esm/index.client.js\",\n \"require\": \"./build/cjs/index.client.js\"\n },\n \"node\": {\n \"import\": \"./build/esm/index.server.js\",\n \"require\": \"./build/cjs/index.server.js\"\n }\n }\n }\n}\n```\n\n`workerd`, `worker`, and `node` all resolve to `index.server.js`. Only `browser` resolves to `index.client.js`. The same export map is present on the `develop` branch, so this is a current packaging issue.\n\n### Expected Result\n\nThe `workerd` and `worker` export conditions should not resolve to code that re-exports `@sentry/node`.\n\n**Minimal fix — remove misleading conditions:**\n\nRemove the `workerd` and `worker` export conditions from `package.json`, since the package does not currently provide Workers-compatible server code. This is a packaging stopgap, not a fully non-breaking resolution:\n\n* **Fallback behavior is toolchain-dependent.** Bundlers whose active condition set includes `browser` (e.g., Vite with `['workerd', 'worker', 'browser', ...]`) will fall through to `index.client.js`, which is safe. But this is not guaranteed across all resolvers — [Node's package docs](\u003chttps://nodejs.org/api/packages.html#conditional-exports>) recommend a `default` branch for unknown runtimes. Whether to add `default` pointing to the client entry is a design call for the Sentry team.\n* **Export surface change.** The `browser`/client entry exports stubs for `wrapMiddlewaresWithSentry`, `sentryGlobalRequestMiddleware`, and `sentryGlobalFunctionMiddleware`, but it does **not** export `wrapFetchWithSentry`. Consumers who import that helper would get a build error. The shared `index.types.ts` still re-exports the full server API surface, so TypeScript types and runtime exports would diverge for Workers consumers.\n\nDespite these caveats, removing the conditions is strictly better than the current state: it stops actively directing Workers bundlers to Node code, and the practical impact is limited since the server helpers don't work on Workers anyway.\n\n**Longer-term — proper Workers entry (follow-up):**\n\nA proper fix would create Worker-specific server modules that use `@sentry/cloudflare` instead of `@sentry/node`. This is non-trivial since `@sentry/node` is imported directly by multiple server source files, not just the barrel. This would likely be a separate design effort, potentially tracked alongside [JS-1388](https://linear.app/getsentry/issue/JS-1388/investigate-cloudflare-support).\n\n### Actual Result\n\nWorker crashes with `\"Cannot initialize ExportedHandler\"` — silent module evaluation failure, no stack trace, no useful output from `wrangler tail`.\n\n\u003c!-- linear:table-colwidths:200,200,200,200 -->\n| Condition resolved | Server entry | What gets bundled | Result on Workers |\n| -- | -- | -- | -- |\n| `workerd` | `index.server.js` | `@sentry/node` + OpenTelemetry + `node:*` | **Silent crash** |\n| `worker` | `index.server.js` | `@sentry/node` + OpenTelemetry + `node:*` | **Silent crash** |\n| `browser` | `index.client.js` | `@sentry/browser` (no Node deps) | Works |\n| `node` | `index.server.js` | `@sentry/node` | Works (Node.js) |\n\n**Workaround:** Replace `@sentry/tanstackstart-react` with `@sentry/react` for runtime imports. Both export `init`, `ErrorBoundary`, and `tanstackRouterBrowserTracingIntegration`. This preserves client-side Sentry but loses the TanStack Start server helpers. For server-side Workers tracking, use `@sentry/cloudflare` separately. The Vite plugin (`@sentry/tanstackstart-react/vite`) is build-time only and unaffected.\n\n### Related issues\n\n* [JS-1388](https://linear.app/getsentry/issue/JS-1388/investigate-cloudflare-support) — Investigate TanStack Start React Cloudflare support\n* [#12620](\u003chttps://github.com/getsentry/sentry-javascript/issues/12620>) — Sentry Cloudflare Workers SDK\n* [JS-348](https://linear.app/getsentry/issue/JS-348/support-nextjs-on-cloudflare-workers-opennext) — Support Next.js on Cloudflare Workers (OpenNext) (same pattern with `@sentry/nextjs`)\n* [JS-1481](https://linear.app/getsentry/issue/JS-1481/cannot-resolve-sentrynextjs-on-cloudflare-workers) — Cannot resolve `@sentry/nextjs` on Cloudflare Workers (same class of bug)\n* [JS-377](https://linear.app/getsentry/issue/JS-377/react-router-v7-deployed-to-cloudflare-workers) — React Router v7 deployed to Cloudflare Workers\n\n### Additional context\n\n**Note:** We are aware the [SDK setup docs](\u003chttps://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/>) note this is still alpha and warn that the setup \"does not currently work for Cloudflare deployments.\" This issue is specifically about the misleading `workerd`/`worker` export conditions — they signal bundler-level compatibility that doesn't exist, causing a silent failure mode that is very difficult to diagnose.\n\n**Environment details:** Cloudflare Workers paid plan, compatibility date `2025-09-01`, `nodejs_compat` enabled. Bundling via Vite 7 (Rolldown) with Nitro `noExternals: true`.\n\nWe observed platform-dependent behavior: macOS local builds sometimes tree-shook enough undici code for the Worker to boot, while Linux CI included the full transport (\\~900 KiB), causing module evaluation failure. This variance is secondary to the export-map mismatch but made diagnosis significantly harder.","author":{"url":"https://github.com/jmalmo","@type":"Person","name":"jmalmo"},"datePublished":"2026-03-30T10:53:09Z","url":"https://github.com/getsentry/sentry-javascript/issues/20038"}
| 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:d5f9a02d-b7fe-efc6-7038-3bd6a2e11284 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCD0:1D4BD6:5FA8B8:865DFB:6B044874 |
| html-safe-nonce | da2b262b21bd7b6d47771b330c28d5422f5f5e0ec97c9d4af6723873eb237315 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0QwOjFENEJENjo1RkE4Qjg6ODY1REZCOjZCMDQ0ODc0IiwidmlzaXRvcl9pZCI6IjY0NDc4Nzg1NTE4MDE5NzI4NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b9ba785292690fd224815087c224432dd46c482800c8ce7b39f6f183a417bed1 |
| hovercard-subject-tag | issue:4169698670 |
| 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/20038/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e798a75039123348c9f0a5fc99432c70f67b3b5142b3d640c4a6de6c438e942e/getsentry/sentry-javascript/issues/20038 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e798a75039123348c9f0a5fc99432c70f67b3b5142b3d640c4a6de6c438e942e/getsentry/sentry-javascript/issues/20038 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues How do you use Sentry? Sentry SaaS (sentry.io) Which SDK are you using?... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jmalmo |
| hostname | github.com |
| expected-hostname | github.com |
| None | d4495c3631faba668036f176d1f5946901c5172efd73a6edb984029e7d4f8e46 |
| 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 | 9ac4337fb7c6a5846cdfdb1a04f154d3c33ebc77 |
| 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