Repository navigation
Description
Description
When using @sentry/sveltekit with Vite 7.x and running svelte-check (or any operation that triggers Vite config resolution), the build fails with:
TypeError: sentryPlugins.find is not a function
at makeCustomSentryVitePlugins (sourceMaps.js:74:55)
at async sentrySvelteKit (sentryVitePlugins.js:64:31)
at async Promise.all (index 0)
at async asyncFlatten (config.js:2574:10)
at async resolveConfig (config.js:35429:68)
Root Cause Analysis
After investigating the source code of @sentry/sveltekit, @sentry/vite-plugin, unplugin, and Vite, I found the issue:
1. unplugin returns inconsistent types
In unplugin@1.0.1 (which @sentry/vite-plugin depends on), the Vite adapter returns either a single plugin OR an array:
// unplugin/src/vite/index.ts
return plugins.length === 1 ? plugins[0] : plugins; // Single object OR array!2. @sentry/sveltekit assumes an array
In @sentry/sveltekit/src/vite/sourceMaps.ts (line 85-87):
const sentryPlugins: Plugin[] = await sentryVitePlugin(mergedOptions);
const sentryViteDebugIdUploadPlugin = sentryPlugins.find( // FAILS if single object!
plugin => plugin.name === 'sentry-vite-debug-id-upload-plugin',
);3. During svelte-check, only one plugin is created
When svelte-check triggers config resolution, something causes sentryVitePlugin() to return only one plugin (likely the noop plugin when auth tokens aren't available), which unplugin converts to a single object instead of an array.
Steps to Reproduce
- Create a SvelteKit project with Vite 7.x
- Install
@sentry/sveltekit - Add
sentrySvelteKit()to vite.config.ts plugins - Run
svelte-checkorsvelte-kit sync && svelte-check
Environment
@sentry/sveltekit: 10.32.1vite: 7.3.0@sveltejs/kit: 2.49.xunplugin(transitive via @sentry/vite-plugin): 1.0.1
Workaround
Adding @sentry/sveltekit to ssr.external prevents Vite from bundling it during SSR/type-checking:
// vite.config.ts
export default defineConfig({
plugins: [
sentrySvelteKit({ /* ... */ }),
sveltekit(),
],
ssr: {
external: ["@sentry/sveltekit"], // Workaround for Vite 7 compatibility
},
});Suggested Fix
Either:
-
Defensive check in sourceMaps.ts: Wrap the result in an array if it's not already:
const sentryPlugins: Plugin[] = [await sentryVitePlugin(mergedOptions)].flat();
-
Update unplugin dependency: The current
@sentry/vite-pluginpinsunplugin@1.0.1(current is 2.3.11). Newer versions may handle this differently. -
Document the workaround: Add
ssr.externalto the SvelteKit setup docs for Vite 7 users.
Related Issues
- It looks like the new version of SvelteKit is incompatible with the @sentry/sveltekit package sveltejs/kit#13869 (different issue but same workaround)
- vite-plugin > Type "" is not assignable to type PluginOption sentry-javascript-bundler-plugins#804 (Vite 7 type compatibility, closed)
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
linear commentedon Jan 8, 2026
JS-1427
nicohrubec commentedon Jan 10, 2026
Hey, thanks for writing in and the detailed investigation! Looks correct to me, I'll discuss internally how we want to handle this and keep you posted.
nicohrubec commentedon Jan 14, 2026
@p0ns I opened a PR for the
@sentry/vite-pluginthat ensures that we always return an array of plugins, which should resolve this issue. Still in review, but hoping we can merge this soonchore(deps): Bump bundler plugins to ^4.6.2 (#18822)
nicohrubec commentedon Jan 16, 2026
@p0ns Should be fixed in the next release! Let us know if you encounter any more issues.
github-actions commentedon Jan 19, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #18822, which was included in the 10.35.0 release.