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

Closed
@jqrd

Description

@jqrd

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: > products@0.1.0 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
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions