Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sentrySvelteKit in vite.config.ts does not upload sourcemaps #15227

Closed
3 tasks done
ktarmyshov opened this issue Jan 29, 2025 · 13 comments
Closed
3 tasks done

sentrySvelteKit in vite.config.ts does not upload sourcemaps #15227

ktarmyshov opened this issue Jan 29, 2025 · 13 comments
Assignees
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK

Comments

@ktarmyshov
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/sveltekit

SDK Version

8.52.0

Framework Version

SvelteKit 2.16.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

vite.config.ts

  plugins: [
    sentrySvelteKit({
      adapter: 'auto',
      sourceMapsUploadOptions: {
        org: <org removed>,
        project: <project removed>,
        authToken: SENTRY_AUTH_TOKEN,
      }
    }),
    sveltekit(),
    purgeCss(),
    // Put the Sentry vite plugin after all other plugins
    // sentryVitePlugin({
    //   org: <org removed>,
    //   project: <project removed>,
    //   authToken: process.env.SENTRY_AUTH_TOKEN,
    // }),

Steps to Reproduce

added (see above) modifications to vite config.
If I use sentryVitePlugin - some uploading is happening at the end of build but BEFORE the adapter is executed
sentrySvelteKit has no effect and does nothing.

Expected Result

sentrySvelteKit plugin should upload sourcemaps.

Actual Result

Nothing seems to be uploaded

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 29, 2025
@github-actions github-actions bot added the Package: sveltekit Issues related to the Sentry SvelteKit SDK label Jan 29, 2025
@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

Hey @ktarmyshov thanks for writing in! Some things to narrow this down:

  • You use adapter-auto, correct? where do you deploy your app to? Is your build command the default vite build command?
  • You don't need to add @sentry/vite-plugin (the one in the comment). It doesn't work by default in SvelteKit due to kit executing the adapter at the very end. sentrySvelteKit should take care of this.

@ktarmyshov
Copy link
Author

@Lms24 Hi, Lukas!

I do use different adapters for different env variables, but when I build for preview, I use adapter-auto - yes. Build command "vite build --mode development"

I tried vite-plugin, to see if there is a difference, and vite-plugin does upload the sourcemaps - I see various log messages, debug id, etc.
But sentrySvelteKit does nothing.

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 30, 2025
@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

Thanks for getting back to me! I tried to reproduce this with adapter-auto but for me source maps were uploaded correctly. See my reproduction repository: https://github.com/Lms24/gh-sentry-javascript-15227-sveltekit-no-sourcemaps

Would you mind pointing out what I need to add in my reproduction so that the bug appears? Otherwise please provide your own reproduction. I can't really see it but any chance that the purgeCss plugin is interfering somehow?

@ktarmyshov
Copy link
Author

Hi, Lukas!
is it supposed to print anything into the STD? I ran npm i, npm run build, see no output, if it's uploading or not finding project, auth token, etc.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 30, 2025
@ktarmyshov
Copy link
Author

Is it possible to enable output debug/trace for the plugin, what it's doing?

@ktarmyshov
Copy link
Author

I got your repo working for me as well, but for my repo it's not working :(

@ktarmyshov
Copy link
Author

found:
if (svelteKitPluginOptions.autoUploadSourceMaps && process.env.NODE_ENV !== 'development') {
that's why

@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

If you set sentrySvelteKit({debug: true}), you should get debug output.

@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

found:
if (svelteKitPluginOptions.autoUploadSourceMaps && process.env.NODE_ENV !== 'development') {
that's why

hmm yes this is a safeguard not to upload when the dev server is running. I'm wondering why the NODE_ENV would be set to development in a prod build though. Usually Vite sets this by itself 🤔

@ktarmyshov
Copy link
Author

I was setting NODE_ENV to development also for build, that's why it wasn't working. So I will close the issue, need to figure out, when to set it and when not to set it :), or do I need to set it at all.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 30, 2025
@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

Oh interesting, I see! If you have a good reason to set NODE_ENV manually, let me know because we rely on it in quite a few places (also in other SDKs and our bundler plugins) and I'm curious about the use case :)

Closing as completed for now.

@ktarmyshov
Copy link
Author

Since sentry print logs when uploading maps, it could be useful to print why it won't upload in case it won't

@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

yeah I agree, let me think about this and the env variable check at this point. it doesn't seem completely sound to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK
Projects
Archived in project
Development

No branches or pull requests

2 participants