Skip to content

Sveltekit build fails with sourcemap deletion enabled #14131

Closed

Description

@dollannn

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/rollup@4.24.3/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.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Oct 29, 2024
  2. Lms24 commented on Oct 30, 2024

    @Lms24
    Member

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

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 30, 2024
  4. dollannn commented on Nov 9, 2024

    @dollannn
    Author

    Any progress on this?

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 9, 2024
  6. Lms24 commented on Nov 11, 2024

    @Lms24
    Member

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

  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Nov 11, 2024
  8. self-assigned this
    on Nov 11, 2024
  9. Lms24 commented on Nov 11, 2024

    @Lms24
    Member

    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.

  10. dollannn commented on Dec 8, 2024

    @dollannn
    Author

    Any updates on this?

  11. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Dec 8, 2024
  12. AbhiPrasad commented on Dec 9, 2024

    @AbhiPrasad
    Contributor

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

  13. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Dec 9, 2024
  14. matthijs166 commented on Dec 29, 2024

    @matthijs166

    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()
    ]
  15. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Dec 29, 2024
  16. Lms24 commented on Jan 2, 2025

    @Lms24
    Member

    Gonna take another look today. Sorry for the wait!

  17. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jan 2, 2025
  18. Lms24 commented on Jan 8, 2025

    @Lms24
    Member

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

  19. ghost added on Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions