Title: [SvelteKit 3] Sentry 11.8 build-time instrumentation breaks PostgreSQL bundling in Azure Functions · Issue #25470 · getsentry/sentry-javascript · GitHub
Open Graph Title: [SvelteKit 3] Sentry 11.8 build-time instrumentation breaks PostgreSQL bundling in Azure Functions · Issue #25470 · getsentry/sentry-javascript
X Title: [SvelteKit 3] Sentry 11.8 build-time instrumentation breaks PostgreSQL bundling in Azure Functions · Issue #25470 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25470
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[SvelteKit 3] Sentry 11.8 build-time instrumentation breaks PostgreSQL bundling in Azure Functions","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/sveltekit\n\n### SDK Version\n\n11.8.0\n\n### Framework Version\n\n\"@sveltejs/kit\": \"^3.1.0\",\n\n### Link to Sentry event\n\nhttps://konstantin-tarmyshov.sentry.io/share/issue/9da37aba11594d27b8c7dcdfc60a1f5e/\n\n### Reproduction Example/SDK Setup\n\n# [SvelteKit 3] Sentry 11.8 build-time instrumentation breaks PostgreSQL bundling in Azure Functions\n\n## Environment\n\n- **Sentry SDK:** `@sentry/sveltekit@11.8.0`\n- **SvelteKit:** 3.1.0\n- **Vite:** 8.3.4\n- **Rolldown:** 1.2.14\n- **PostgreSQL driver:** `pg@8.23.1`\n- **Deployment:** Azure Static Web Apps / Azure Functions, Node.js 22\n- **Adapter:** `@ktarmyshov/svelte-adapter-azure-swa`\n\nThe adapter uses a two-stage build: SvelteKit/Vite produces the first SSR bundle, then the adapter runs a separate Rolldown pass to generate the deployable Azure Functions output.\n\n## Problem\n\nWith Sentry enabled, a simple SvelteKit endpoint importing `Client` from `pg` fails in Azure:\n\n```text\nError: Cannot find module 'pg-types'\nRequire stack:\n- /home/site/wwwroot/sk_render/_server.ts-\u003chash>.js\n```\n\nPublic Sentry event:\n\nhttps://konstantin-tarmyshov.sentry.io/share/issue/9da37aba11594d27b8c7dcdfc60a1f5e/\n\nThe endpoint does not connect to a database:\n\n```ts\nimport { Client } from 'pg';\n\nexport function GET() {\n return new Response(typeof Client);\n}\n```\n\nThe failure disappears when either:\n\n1. `pg` is explicitly externalized during the initial Vite SSR build.\n2. Sentry is completely removed, without any explicit externalization.\n\nBoth alternatives have been verified on **real Azure deployments**, not just local builds.\n\n## Three verified Azure experiments\n\n### A. Sentry enabled, default SSR configuration — FAIL\n\n**Commit:**\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/commit/473db3c5835c2295d8c2dec00bf703f079a70bb0\n\n**Failing Azure job:**\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/actions/runs/38960205600/job/117173179946\n\n**Result:** 39 passed, 1 failed.\n\nThe PostgreSQL smoke endpoint returns HTTP 500 instead of 200.\n\nThe first Vite SSR stage produces an approximately **801 KB** PostgreSQL endpoint bundle containing unresolved CommonJS calls:\n\n```js\n__require(\"pg-types\")\n__require(\"pg-protocol\")\n__require(\"pgpass\")\n__require(\"pg-cloudflare\")\n__require(\"pg-connection-string\")\n```\n\nThese calls survive the adapter's second Rolldown bundling pass and fail during Azure Functions execution.\n\n### B. Sentry enabled, `ssr.external: ['pg']` — PASS\n\n**Commit:**\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/commit/7a1f50fcbb107df8f67a1e07de3f12f75168072e\n\n**Successful Azure job:**\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/actions/runs/38961408425/job/117177863220\n\n**Result:** 40 passed, including PostgreSQL and both Sentry error-ingestion tests.\n\n**Exact comparison of the failing and passing commits:**\n\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/compare/473db3c5835c2295d8c2dec00bf703f079a70bb0...7a1f50fcbb107df8f67a1e07de3f12f75168072e\n\nThe only functionally relevant change is:\n\n```ts\nssr: {\n external: ['pg']\n}\n```\n\nThe first Vite SSR bundle now retains an ordinary import:\n\n```js\nimport { Client } from \"pg\";\n```\n\nThe second Rolldown pass successfully bundles PostgreSQL and its dependencies.\n\n**However, Sentry explicitly warns:**\n\n```text\n[Sentry] The following packages are marked as external\nin your bundler configuration but need to be bundled\nfor Sentry instrumentation to work: pg.\n\nRemove them from your bundler's \"external\" configuration,\nor use the Sentry Node SDK's runtime instrumentation instead.\n```\n\nTherefore, the workaround fixes deployment but may prevent automatic PostgreSQL instrumentation.\n\nPassing the Sentry error-ingestion tests does not prove that PostgreSQL performance tracing remains functional.\n\n### C. Sentry removed, no `ssr.external` workaround — PASS\n\n**Diagnostic draft PR:**\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/pull/335\n\n**Successful Azure job:**\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/actions/runs/38966384532/job/117194085562\n\n**Result:** 38 passed, including PostgreSQL.\n\nThis experiment completely removes Sentry SDK dependencies, its Vite plugin, hooks, server instrumentation, tracing configuration, and Sentry-specific tests.\n\nThe adapter and PostgreSQL smoke endpoint remain unchanged. No `ssr.external: ['pg']` workaround is present.\n\nThe first Vite SSR PostgreSQL endpoint is now approximately **0.20 KB**, and the generated Azure Function works correctly.\n\nThis is a broader Sentry-removal experiment, not a Vite-plugin-only isolation. It establishes that the failure disappears without Sentry, but does not identify the exact responsible hook.\n\n## Suspected cause\n\nInvestigation of the resolved Vite configuration with Sentry enabled showed that `pg`, `pg-pool`, and numerous other instrumented packages were present in:\n\n- `ssr.noExternal`\n- `environments.ssr.resolve.noExternal`\n\nThis appears to force PostgreSQL into the initial SSR bundle, producing partially bundled CommonJS code with unresolved runtime `__require()` calls.\n\nBuild-time resolver diagnostics confirmed that the PostgreSQL dependencies could be resolved. The unresolved calls are introduced into the generated output.\n\nWithout Sentry, Vite leaves PostgreSQL external in the first stage, allowing the downstream bundler to process its original dependency graph.\n\nWe suspect Sentry's build-time instrumentation / Orchestrion integration is responsible for this change in externalization behavior. However, the precise plugin hook has not yet been isolated.\n\n## Related issues\n\nThis appears similar to existing problems with build-time instrumentation in other Sentry framework integrations:\n\n- **#24775** — `@sentry/nuxt` 11: CommonJS packages inlined for build-time instrumentation break in the Nitro bundle. Fixed for Nuxt in Sentry 11.2.0.\n- **#25339** — `@sentry/react-router` 11: build-time instrumentation inlines CommonJS, causing server startup failures. Currently open.\n\nRelated Rolldown investigations: [[#10643](https://github.com/rolldown/rolldown/issues/10643)](https://github.com/rolldown/rolldown/issues/10643) and [[#9407](https://github.com/rolldown/rolldown/issues/9407)](https://github.com/rolldown/rolldown/issues/9407).\n\n## Expected behavior\n\nSentry's build-time instrumentation should not cause an otherwise working PostgreSQL dependency to become partially bundled and fail after downstream server bundling.\n\nIdeally, PostgreSQL instrumentation should remain functional without requiring `ssr.external: ['pg']`.\n\n## Questions\n\n1. Does the SvelteKit Sentry integration intentionally force `pg` into `ssr.noExternal` through build-time instrumentation?\n2. Is this the same class of problem addressed for Nuxt in #24775, and could the SvelteKit integration require a similar fix?\n3. Is there a supported way to retain PostgreSQL instrumentation in a two-stage SvelteKit/Azure Functions build without forcing `pg` to be external?\n\nAll three configurations have publicly accessible commits and successful or failing real Azure E2E jobs.\n\nThe diagnostic no-Sentry PR is intentionally marked **do not merge**. We want to retain Sentry and its database instrumentation in the actual application.\n\n### Steps to Reproduce\n\nThree verified Azure experiments\n\nA. Sentry enabled, default SSR configuration — FAIL\n\nCommit:\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/commit/473db3c5835c2295d8c2dec00bf703f079a70bb0\n\nFailing Azure job:\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/actions/runs/38960205600/job/117173179946\n\nResult: 39 passed, 1 failed.\n\nThe PostgreSQL smoke endpoint returns HTTP 500 instead of 200.\n\nThe first Vite SSR stage produces an approximately 801 KB PostgreSQL endpoint bundle containing unresolved CommonJS calls:\n\n__require(\"pg-types\")\n__require(\"pg-protocol\")\n__require(\"pgpass\")\n__require(\"pg-cloudflare\")\n__require(\"pg-connection-string\")\n\nThese calls survive the adapter's second Rolldown bundling pass and fail during Azure Functions execution.\n\nB. Sentry enabled, ssr.external: ['pg'] — PASS\n\nCommit:\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/commit/7a1f50fcbb107df8f67a1e07de3f12f75168072e\n\nSuccessful Azure job:\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/actions/runs/38961408425/job/117177863220\n\nResult: 40 passed, including PostgreSQL and both Sentry error-ingestion tests.\n\nExact comparison of the failing and passing commits:\n\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/compare/473db3c5835c2295d8c2dec00bf703f079a70bb0...7a1f50fcbb107df8f67a1e07de3f12f75168072e\n\nThe only functionally relevant change is:\n\nssr: {\n external: ['pg']\n}\n\nThe first Vite SSR bundle now retains an ordinary import:\n\nimport { Client } from \"pg\";\n\nThe second Rolldown pass successfully bundles PostgreSQL and its dependencies.\n\nHowever, Sentry explicitly warns:\n\n[Sentry] The following packages are marked as external\nin your bundler configuration but need to be bundled\nfor Sentry instrumentation to work: pg.\n\nRemove them from your bundler's \"external\" configuration,\nor use the Sentry Node SDK's runtime instrumentation instead.\n\nTherefore, the workaround fixes deployment but may prevent automatic PostgreSQL instrumentation.\n\nPassing the Sentry error-ingestion tests does not prove that PostgreSQL performance tracing remains functional.\n\nC. Sentry removed, no ssr.external workaround — PASS\n\nDiagnostic draft PR:\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/pull/335\n\nSuccessful Azure job:\nhttps://github.com/kt-npm-modules/svelte-adapter-azure-swa/actions/runs/38966384532/job/117194085562\n\nResult: 38 passed, including PostgreSQL.\n\nThis experiment completely removes Sentry SDK dependencies, its Vite plugin, hooks, server instrumentation, tracing configuration, and Sentry-specific tests.\n\nThe adapter and PostgreSQL smoke endpoint remain unchanged. No ssr.external: ['pg'] workaround is present.\n\nThe first Vite SSR PostgreSQL endpoint is now approximately 0.20 KB, and the generated Azure Function works correctly.\n\nThis is a broader Sentry-removal experiment, not a Vite-plugin-only isolation. It establishes that the failure disappears without Sentry, but does not identify the exact responsible hook.\n\n### Expected Result\n\nDefault SvelteKit App config, default Sentry config -> pg* are bundled -> deployment to SWA works\n\n### Actual Result\n\nDefault SvelteKit App config, default Sentry config -> pg* are NOT bundled -> deployment to SWA FAILS\n\n### Additional Context\n\n_No response_\n\n### Priority\n\n_No response_","author":{"url":"https://github.com/ktarmyshov","@type":"Person","name":"ktarmyshov"},"datePublished":"2026-10-16T21:20:29Z","url":"https://github.com/getsentry/sentry-javascript/issues/25470"}
| 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:62d229f6-33f9-980c-df30-35966da9af23 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C7B2:D405E:2C64EFC:39A9743:6B0412B0 |
| html-safe-nonce | 0c788a410c0276ba8bb7c104bed9c960636e9fbc30c32c81ea14858930b71c16 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDN0IyOkQ0MDVFOjJDNjRFRkM6MzlBOTc0Mzo2QjA0MTJCMCIsInZpc2l0b3JfaWQiOiIzMzk4NjA3MDE3NTI5ODQwMzA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7fc53bfb67e2864fd2954b9d1d599af0945515f4873abc483f59777c3ea6f5cf |
| hovercard-subject-tag | issue:5891356836 |
| 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/25470/issue_layout |
| twitter:image | https://opengraph.githubassets.com/13c3a6690321e9aa04b4bf7aa3bbf89253fbcf73d0ca78a84df5c2af0a09a94d/getsentry/sentry-javascript/issues/25470 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/13c3a6690321e9aa04b4bf7aa3bbf89253fbcf73d0ca78a84df5c2af0a09a94d/getsentry/sentry-javascript/issues/25470 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ktarmyshov |
| 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