Skip to content

@sentry/nextjs v8.49.0 deletes sourcemap files by default, disregards sourcemaps.deleteFilesAfterUpload:false, causes next-sitemap to fail during build #15133

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

Closed
3 tasks done
jqrd opened this issue Jan 22, 2025 · 3 comments
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@jqrd
Copy link

jqrd commented Jan 22, 2025

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.49.0

Framework Version

Next 15.1.5

Link to Sentry event

No response

Reproduction Example/SDK Setup

// Sentry init
Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
  tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE_FLOAT
    ? parseFloat(process.env.NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE_FLOAT)
    : 0.01,
});
// Next config using withSentryConfig
module.exports = withSentryConfig(nextConfig, {
  org: 'orgName',
  project: 'products',

  // Only print logs for uploading source maps in CI
  silent: !process.env.CI,

  // Upload a larger set of source maps for prettier stack traces (increases build time)
  widenClientFileUpload: true,

  // Hides source maps from generated client bundles
  hideSourceMaps: true,

  // Automatically tree-shake Sentry logger statements to reduce bundle size
  disableLogger: true,

  // also fails without this whole section being present, and it also used to work without it being there at all
  sourcemaps: {
    // Ensure sourcemaps are left behind by Sentry so that next-sitemap can use them
    deleteSourcemapsAfterUpload: false,
  },
});

Steps to Reproduce

Set up a Next project with Sentry integration.

Add next-sitemap as a dependency, e.g. pnpm add next-sitemap / npm install next-sitemap.

Add a next-sitemap.config.js file:

module.exports = {
  siteUrl: 'https://www.example.com',
  generateIndexSitemap: false,
  sitemapSize: 1000000,
};

Add a postbuild step in package.json:

    "postbuild": "next-sitemap",

Set a valid SENTRY_DSN env variable value and run pnpm build / npm build.

Expected Result

Postbuild step succeeds in generating the sitemap -- this is working on v8.48.0

Actual Result

Error in postbuild step:

...
11:20:08 AM: products:build: [@sentry/nextjs - Node.js] Info: Successfully uploaded source maps to Sentry
11:20:08 AM: products:build: 
11:20:08 AM: products:build: > [email protected] postbuild /opt/build/repo/apps/products
11:20:08 AM: products:build: > next-sitemap
11:20:08 AM: products:build: 
11:20:08 AM: products:build: ✨ [next-sitemap] Loading next-sitemap config: file:///opt/build/repo/apps/products/next-sitemap.config.js
11:20:08 AM: products:build:  ❌ [next-sitemap] Unable to find build-manifest.
11:20:08 AM: products:build: Make sure to build the project using `next build` command
11:20:08 AM: products:build: 
11:20:08 AM: products:build:  ❌ [next-sitemap] undefined
...
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 22, 2025
@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Jan 22, 2025
@jqrd jqrd changed the title @sentry/nextjs v8.49.0 deletes sourcemap files by default, disregards sourcemaps.deleteFilesAfterUpload:false @sentry/nextjs v8.49.0 deletes sourcemap files by default, disregards sourcemaps.deleteFilesAfterUpload:false, causes next-sitemap to fail during build Jan 22, 2025
@jqrd
Copy link
Author

jqrd commented Jan 22, 2025

There seems to be one recent change in the area, from the title it seems to be specifically for sveltekit but I haven't dug into it: #14963

@lforst
Copy link
Member

lforst commented Jan 22, 2025

Hi, I cannot reproduce what you are describing. Would you mind sharing a reproduction repo we could pull to look at this?

@jqrd
Copy link
Author

jqrd commented Jan 22, 2025

Apologies, when trying to narrow this down further it seems like we also upgraded @sentry/webpack-plugin from 2.23.0 to 3.0.0, and that may be actual cause of the issue. I'll file a separate issue when I can confirm this.

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

No branches or pull requests

2 participants