Repository navigation
@sentry/sveltekit: loading the Vite config deletes the adapter-node 6 output directory (build/) #25186
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/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/sveltekit
SDK Version
10.76.1
Framework Version
SvelteKit 3.0.1, @sveltejs/adapter-node 6.0.0, Vite 8.2.2, Svelte 5.57.2
Link to Sentry event
Not applicable (build-time behaviour).
Reproduction Example/SDK Setup
vite.config.ts:
import adapter from '@sveltejs/adapter-node';
import { sentrySvelteKit } from '@sentry/sveltekit';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
sentrySvelteKit({ org: 'my-org', project: 'my-project', authToken: process.env.SENTRY_AUTH_TOKEN }),
sveltekit({ adapter: adapter() })
]
});Minimal script that calls the SDK's adapter probe the way sentrySvelteKit() does on every config load:
// probe.cjs
const fs = require('node:fs');
const { getAdapterOutputDir } = require('@sentry/sveltekit/build/cjs/vite/svelteConfig.js');
(async () => {
const { default: adapter } = await import('@sveltejs/adapter-node');
fs.mkdirSync('build', { recursive: true });
fs.writeFileSync('build/probe', 'x');
console.log('before:', fs.existsSync('build/probe'));
console.log('probe returned:', await getAdapterOutputDir({ adapter: adapter() }, 'node'));
console.log('after :', fs.existsSync('build/probe'), fs.existsSync('build'));
})();Output:
before: true
probe returned: build
after : false false
Steps to Reproduce
- SvelteKit 3 project with
@sveltejs/adapter-node6 andsentrySvelteKit()in the Vite plugins. vite build(output lands inbuild/).- Load the Vite config again in any way, for example
svelte-kit sync(whichsvelte-checksetups run first),vite dev, orvite buildof another project in the same cwd. ls build– the directory is gone.
Same project, same steps with sentrySvelteKit() removed from the plugins: build/ survives svelte-kit sync.
Expected Result
Detecting the adapter's output directory has no side effects on disk. The build output only disappears when the adapter is actually run by vite build.
Actual Result
getAdapterOutputDir (packages/sveltekit/src/vite/svelteConfig.ts) discovers the output directory by calling the real adapter's adapt() with a stub builder whose rimraf is a no-op and whose writeClient throws to escape early:
const adapterBuilder = {
writeClient(dest) {
outputDir = dest.replace(/\/client.*/, '');
throw new Error('We got what we came for, throwing to exit the adapter');
},
rimraf: () => {},
mkdirp: () => {},
...
};
await nodeAdapter.adapt(adapterBuilder);That relies on the adapter clearing its output through builder.rimraf. adapter-node 5 did (builder.rimraf(out)); adapter-node 6 clears it directly before anything else:
// @sveltejs/adapter-node 6.0.0, index.js
async adapt(builder) {
fs.rmSync(out, { force: true, recursive: true });
...
builder.writeClient(client_dir);So the probe deletes the real build/ directory every time the Vite config is loaded, which with SvelteKit 3 happens on svelte-kit sync, svelte-check, vite dev and vite build. The probe still returns the right directory, so nothing in the build log hints at it.
Additional Context
- The probe's
adapt()call is the only@sentry/sveltekitcode path involved; thesourcemapsdeletion globs are not reached (no upload is configured in the minimal repro). - In a CI image that builds and copies in one step this goes unnoticed. Locally, running
svelte-checkafter a build silently removes the build, which is how we found it. - A probe that does not execute adapter code (a static table of default output dirs per adapter name, or an explicit
adapter/outputDiroption taking precedence) would avoid the coupling to how adapters clean up. Alternatively, run the adapter inside a temporary cwd. - Related: @sentry/sveltekit: source maps are never uploaded with SvelteKit 3 #25096 / fix(sveltekit): Upload source maps with SvelteKit 3 #25139 (reading the Kit 3 config from the Vite plugin) touch the same file.
Priority
P2 (Medium)
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Oct 8, 2026
JS-3896
chargome commentedon Oct 8, 2026
@jose-manuel-silva thanks for raising, we'll look into it right away
fix(sveltekit): Stop adapter-node 6 output dir probe from deleting th…
fix(sveltekit): Stop adapter-node 6 output dir probe from deleting th…
github-actions commentedon Oct 12, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #25193, which was included in the 11.7.0 release.