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

Sveltekit build fails with sourcemap deletion enabled #14131

Closed
3 tasks done
dollannn opened this issue Oct 29, 2024 · 9 comments · Fixed by #14942
Closed
3 tasks done

Sveltekit build fails with sourcemap deletion enabled #14131

dollannn opened this issue Oct 29, 2024 · 9 comments · Fixed by #14942
Assignees
Labels
Package: svelte Issues related to the Sentry Svelte SDK

Comments

@dollannn
Copy link

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/sveltekit

SDK Version

8.35.0

Framework Version

Latest svelte

Link to Sentry event

No response

Reproduction Example/SDK Setup

Latest svelte 5 repro, I am myself using svelte 4 in the project actually being affected by this:

https://github.com/dollannn/sentry-repro

Steps to Reproduce

Enable sourcemap deletion in vite.config.ts
Try to build

error during build

Expected Result

Sourcemaps being deleted and the build not failing

Actual Result

error during build:
Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s)oon exit:
on exit:
on exit:
(sentry-file-deletion-plugin) writeBundle
at process.handleBeforeExit (file:///D:/Projects/test/sentry-repro/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:21098:28)
at Object.onceWrapper (node:events:634:26)
at process.emit (node:events:531:35)
 ELIFECYCLE  Command failed with exit code 1.

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

Lms24 commented Oct 30, 2024

Hey, thanks for reporting! I'll take a look soon.

@dollannn
Copy link
Author

dollannn commented Nov 9, 2024

Any progress on this?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Nov 9, 2024
@Lms24
Copy link
Member

Lms24 commented Nov 11, 2024

Hey, sorry for the wait! Taking a look right now

@Lms24
Copy link
Member

Lms24 commented Nov 11, 2024

So, I have some preliminary findings but unfortunately no fix yet.
A couple of months ago, we changed how we wait with deleting files until they're fully processed in the @sentry/vite-plugin. Unfortunately, these plugin changes had some side effects in the SvelteKit package because the sentrySvelteKit vite plugin function modifies the @sentry/vite-plugin function quite a lot to make it work with SvelteKit'S build config.
This currently leads to the plugin awaiting a promise that doesn't resolve correctly. I'm gonna debug this a bit more tomorrow and hopefully find a fix.

@dollannn
Copy link
Author

dollannn commented Dec 8, 2024

Any updates on this?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 8, 2024
@AbhiPrasad
Copy link
Member

Hi @dollannn, currently no updates, but we'll take another look this week!

@matthijs166
Copy link

matthijs166 commented Dec 29, 2024

Got the same problem here! I would say this is an important feature.

Also, this should be an option enabled by default (just like in the Next.js plugin with hideSourceMaps and deleteSourcemapsAfterUpload)

Deploying the source map by default in production is not good practice!

Also think the warning it should give is not triggering:

console.warn(
`[Source Maps Plugin] We recommend setting the \`sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload\` option to clean up source maps after uploading.
[Source Maps Plugin] Otherwise, source maps might be deployed to production, depending on your configuration`,
);

For now I made my own vite plugin to remove the maps from the client after build and upload:

function removeSourceMapPlugin() {
    return {
        name: 'remove-client-source-maps',
        apply: 'build',
        enforce: 'post',
        generateBundle(_, bundle) {
            for (const file in bundle) {
                if (file.endsWith('.map')) {
                    delete bundle[file]
                }
            }
        }
    };
}

based on: vitejs/vite#12828

Included this in the vite config after the sveltekit plugin:

plugins: [
    sentrySvelteKit({
       // CONFIG
    }),
    sveltekit(),
    removeSourceMapPlugin()
]

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 29, 2024
@Lms24
Copy link
Member

Lms24 commented Jan 2, 2025

Gonna take another look today. Sorry for the wait!

@Lms24
Copy link
Member

Lms24 commented Jan 8, 2025

I opened #14942 to fix this, there will be an automatic response in this issue once the fix is merged and released

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