To recreate this project with the same configuration:
npx [email protected] create --template minimal --types ts --add sveltekit-adapter="adapter:node" --install npm .
npm install @sentry/[email protected] --save
Follow instructions from https://docs.sentry.io/platforms/javascript/guides/sveltekit/manual-setup/
src/hooks.client.ts: configure Sentry and handleError hook for the clientsvelte.config.js: set config.kit.experimental.instrumentation.server = truesrc/instrumentation.server.ts: configure Sentry for the serversrc/hooks.server.ts: configure handleError and handle hooks for the servervite.config.ts: set build.sourcemap = true and configure sentrySvelteKit pluginSet up a route with PageLoad in +page.ts and Actions in +page.server.ts. Throw an error in Actions.
The thrown error is captured but incorrectly source mapped in Sentry.
During npm run build - Sentry seems to inject debug ids after the SvelteKit build stage (.svelte-kit), which seems to emit files that map 1:1 to source files.
Then the @sveltekit/adapter-node stage (build) merges some files - in this case +page.ts and +page.server.ts gets merged into a single output file.
This messes up Sentry source mapping, because the merged file effectively has debug ids injected twice:
grep -rl "Sentry Test Error" build | xargs cat
Note that the sourcemap emitted by SvelteKit+adapter-node build correctly references both original source files,
but the Sentry sourcemap upload only registers the first debug id in the file
and thus can not correctly source map the error that originates 'under' the second debug id (in +page.server.ts).
This is why I believe this to be a Sentry issue and not an issue with the SvelteKit adapter or build process.