-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed as not planned
Closed as not planned
Copy link
Labels
BugPackage: sveltekitIssues related to the Sentry SvelteKit SDKIssues related to the Sentry SvelteKit SDKStale
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?
Self-hosted/on-premise
Which SDK are you using?
@sentry/sveltekit
SDK Version
^8.42.0
Framework Version
^2.0.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
Hello!
I have a monorepo (link) with a SvelteKit client. When deploying my app to production, node build command fails because it can't find @sentry/sveltkit module in server hooks chunks.
My application is deployed on a Scalingo instance, and is using the node-adapter.
I used npx @sentry/wizard@latest -i sveltekit to install Sentry.
"Unfortunately", it works well locally, I can't reproduce the error.
I also tried to install Sentry manually, but the result is the same.
- client/package.json
{
"name": "@boris/client",
"version": "1.0.0",
"private": true,
"engines": {
"node": "20.18.0",
"npm": "10"
},
"scripts": {
"dev": "vite dev",
"build": "vite build",
"start": "node build",
"preview": "vite preview",
"test": "npm run test:integration && npm run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:e2e": "playwright test",
"test:unit": "vitest"
},
"devDependencies": {
"@csstools/postcss-global-data": "^3.0.0",
"@gouvfr/dsfr": "^1.12.1",
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-node": "^5.2.9",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
"eslint-plugin-svelte": "^2.36.0",
"globals": "^15.0.0",
"husky": "^9.1.6",
"nanoid": "^5.0.8",
"papaparse": "^5.4.1",
"postcss": "^8.4.49",
"postcss-custom-media": "^11.0.5",
"prettier-plugin-svelte": "^3.1.2",
"svelte": "5.1.12",
"svelte-check": "^4.0.0",
"vite": "^5.0.3",
"vitest": "^2.0.0"
},
"dependencies": {
"@sentry/sveltekit": "^8.42.0"
},
"type": "module"
}- client/vite.config.ts
import { sentrySvelteKit } from '@sentry/sveltekit';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [
sentrySvelteKit({
sourceMapsUploadOptions: {
org: 'boris',
project: 'client',
url: 'https://sentry.incubateur.net/',
},
adapter: 'node',
}),
sveltekit(),
],
test: {
include: ['tests/unit/**/*.{test,spec}.{js,ts}'],
},
});
- client/src/hooks.server.ts
import { sequence } from '@sveltejs/kit/hooks';
import { handleErrorWithSentry, sentryHandle } from '@sentry/sveltekit';
import Sentry from '@sentry/sveltekit';
Sentry.init({
dsn: 'https://[email protected]/207',
tracesSampleRate: 1.0,
// uncomment the line below to enable Spotlight (https://spotlightjs.com)
// spotlight: import.meta.env.DEV,
});
// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.
export const handle = sequence(sentryHandle());
// If you have a custom error handler, pass it to `handleErrorWithSentry`
export const handleError = handleErrorWithSentry();Thanks in advance π π
Steps to Reproduce
- Use wizzard to install Sentry on a sveltekit app
- Deploying app on Scalingo
- Build succeeds
node buildcommand fails
Expected Result
@sentry/sveltekit module should be found on SvelteKit's server hook during node build
Actual Result
2024-12-04 10:06:22.967657174 +0100 CET [manager] container [web-1] (67501b789982697789ed7927) started
2024-12-04 10:06:23.237611209 +0100 CET [web-1] > @boris/[email protected] start
2024-12-04 10:06:23.237623402 +0100 CET [web-1] > node build
2024-12-04 10:06:23.336066668 +0100 CET [web-1] at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
2024-12-04 10:06:23.336067187 +0100 CET [web-1] at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
2024-12-04 10:06:23.336059994 +0100 CET [web-1] throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
2024-12-04 10:06:23.336051097 +0100 CET [web-1] node:internal/modules/esm/resolve:854
2024-12-04 10:06:23.336067664 +0100 CET [web-1] at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
2024-12-04 10:06:23.336060834 +0100 CET [web-1] ^
2024-12-04 10:06:23.336061872 +0100 CET [web-1] Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@sentry/sveltekit' imported from /app/build/server/chunks/hooks.server-C7Jx9NsL.js
2024-12-04 10:06:23.336068706 +0100 CET [web-1] at link (node:internal/modules/esm/module_job:95:36) {
2024-12-04 10:06:23.336068179 +0100 CET [web-1] at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40)
2024-12-04 10:06:23.336062544 +0100 CET [web-1] at packageResolve (node:internal/modules/esm/resolve:854:9)
2024-12-04 10:06:23.336069085 +0100 CET [web-1] code: 'ERR_MODULE_NOT_FOUND'
2024-12-04 10:06:23.336062995 +0100 CET [web-1] at moduleResolve (node:internal/modules/esm/resolve:927:18)
2024-12-04 10:06:23.336069492 +0100 CET [web-1] }
2024-12-04 10:06:23.336070139 +0100 CET [web-1] Node.js v20.18.0
2024-12-04 10:06:23.336063436 +0100 CET [web-1] at defaultResolve (node:internal/modules/esm/resolve:1169:11) Metadata
Metadata
Assignees
Labels
BugPackage: sveltekitIssues related to the Sentry SvelteKit SDKIssues related to the Sentry SvelteKit SDKStale
Projects
Status
Waiting for: Community