Title: sentrySvelteKit() deletes the adapter output directory (build/) on every serve-mode config load (vitest, vite dev) with @sveltejs/adapter-node 6 · Issue #25532 · getsentry/sentry-javascript · GitHub
Open Graph Title: sentrySvelteKit() deletes the adapter output directory (build/) on every serve-mode config load (vitest, vite dev) with @sveltejs/adapter-node 6 · Issue #25532 · getsentry/sentry-javascript
X Title: sentrySvelteKit() deletes the adapter output directory (build/) on every serve-mode config load (vitest, vite dev) with @sveltejs/adapter-node 6 · Issue #25532 · getsentry/sentry-javascript
Description: Outcome @sentry/sveltekit's vite plugin deletes the adapter output directory (default build/) on every vite config load in serve mode — any vitest run and any vite dev server start — when the project uses @sveltejs/adapter-node@6. Backgr...
Open Graph Description: Outcome @sentry/sveltekit's vite plugin deletes the adapter output directory (default build/) on every vite config load in serve mode — any vitest run and any vite dev server start — when the proje...
X Description: Outcome @sentry/sveltekit's vite plugin deletes the adapter output directory (default build/) on every vite config load in serve mode — any vitest run and any vite dev server start — when the p...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25532
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sentrySvelteKit() deletes the adapter output directory (build/) on every serve-mode config load (vitest, vite dev) with @sveltejs/adapter-node 6","articleBody":"### Outcome\n\n`@sentry/sveltekit`'s vite plugin deletes the adapter output directory (default `build/`) on **every vite config load in serve mode** — any `vitest` run and any `vite dev` server start — when the project uses `@sveltejs/adapter-node@6`.\n\n### Background\n\nIn a SvelteKit 3 project (vite 8 / rolldown-vite, vitest 5) whose `vite.config.ts` contains `sentrySvelteKit()` (default options) and `sveltekit({ adapter: adapter() })` from `@sveltejs/adapter-node@6.0.0`:\n\n1. `sentrySvelteKit()` always adds the `sentry-sveltekit-global-values-injection-plugin` (when `autoUploadSourceMaps` is the default `true`, regardless of `command`).\n2. That plugin's `configResolved` hook *eagerly* resolves the adapter output dir (`getAdapterOutputDir` in `packages/sveltekit/src/vite/svelteConfig.ts`).\n3. `getNodeAdapterOutputDir()` learns the directory by **executing the real adapter's `adapt()` against a stub Builder**: the stub's `writeClient(dest)` records `dest` and throws to short-circuit.\n4. `@sveltejs/adapter-node@6`'s `adapt()` begins with a direct filesystem call — `fs.rmSync(out, { force: true, recursive: true })` (`adapter-node/index.js`, first statement) — which the stub Builder cannot intercept (adapter-node 5 routed this through `builder.rimraf()`, which the stub no-ops). The real `build/` directory is deleted before the stub ever receives a call.\n\nBecause this happens in `configResolved`, it fires in serve mode too: every `vitest` run and every `vite dev` start wipes `build/`. In a `vitest`-then-`e2e` pipeline that serves the previously built output, the e2e web server dies with `Cannot find module …/build`.\n\n### Minimal reproduction\n\nAny vitest run in such a project deletes `build/`. The call path can also be proven with no vite/vitest at all:\n\n```js\n// repro.mjs — run from a SvelteKit app with @sentry/sveltekit and @sveltejs/adapter-node@6 installed\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport adapter from '@sveltejs/adapter-node';\n\nconst require = createRequire(import.meta.url);\nconst pkgDir = dirname(require.resolve('@sentry/sveltekit/package.json'));\nconst { getAdapterOutputDir } = await import(\n\tpathToFileURL(join(pkgDir, 'build/esm/vite/svelteConfig.js')).href // src/vite/svelteConfig.ts when built from source\n);\n\nconsole.log('build/ before:', existsSync('build')); // true (after `vite build`)\nconst out = await getAdapterOutputDir({ adapter: adapter() }, 'node');\nconsole.log('detected output dir:', out); // \"build\"\nconsole.log('build/ after:', existsSync('build')); // false — deleted\n```\n\nOutput:\n\n```\nbuild/ before: true\ndetected output dir: build\nbuild/ after: false\n```\n\n### Why the stub Builder can't help\n\nThe stub in `getNodeAdapterOutputDir` implements `writeClient`, `log`, `getBuildDirectory`, `rimraf`, `mkdirp` and `config`. adapter-node 6 does its cleanup with a direct `fs.rmSync` before it calls any Builder method, so executing `adapt()` at all is destructive, no matter how defensive the stub is.\n\n### Suggested directions\n\n- Resolve the adapter output dir lazily/only in build mode (the value feeds source-map upload and global-value injection that only matter at build time), so serve-mode config loads never execute `adapt()`.\n- Or stop executing the real adapter to learn the directory — e.g. read it from the adapter instance/config, or ask adapter authors to expose it.\n\n### Versions\n\n- `@sentry/sveltekit` 11.6.0 (`@sentry/bundler-plugins` 11.6.0)\n- `@sveltejs/kit` 3.0.1, `@sveltejs/adapter-node` 6.0.0\n- vite 8.3.4, vitest 5.0.3, Node 24.20.0 (Windows; the `fs.rmSync` is platform-independent)\n","author":{"url":"https://github.com/luksluki","@type":"Person","name":"luksluki"},"datePublished":"2026-10-19T15:14:01Z","url":"https://github.com/getsentry/sentry-javascript/issues/25532"}
| 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:f62fcafa-d243-b686-461f-9a3713852b93 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE34:30B4F6:1088CCB:158DDD7:6B0532C4 |
| html-safe-nonce | 1a28531ab8f1af901eac7ef9a8276ab4c424ee580fad93854ad95108aeb8aebd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTM0OjMwQjRGNjoxMDg4Q0NCOjE1OERERDc6NkIwNTMyQzQiLCJ2aXNpdG9yX2lkIjoiNjA3NDI3NjI2ODg5NDEzOTA3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bc5a61d17e73a9d46413602690b8f7260830062abe8bfc3f97a384ff9cb4ce85 |
| hovercard-subject-tag | issue:5926520712 |
| 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/25532/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c9b94982531fe7d2240de48b1985a8935a3b5b360160702c7179c7fa278bb585/getsentry/sentry-javascript/issues/25532 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c9b94982531fe7d2240de48b1985a8935a3b5b360160702c7179c7fa278bb585/getsentry/sentry-javascript/issues/25532 |
| og:image:alt | Outcome @sentry/sveltekit's vite plugin deletes the adapter output directory (default build/) on every vite config load in serve mode — any vitest run and any vite dev server start — when the proje... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | luksluki |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| 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 | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| 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