Skip to content

Sourcemaps are not being uploaded in @sentry/nextjs v7 without adding sourcemaps in webpack configuration #12997

Closed as not planned

Description

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

7.118.0

Framework Version

Next: "12.3.0", @sentry/webpack-plugin: "1.21.0"

Link to Sentry event

No response

SDK Setup/Reproduction Example

import * as Sentry from '@sentry/nextjs';
 import { getWebsiteVersion } from '**/constantsHelper';

Sentry.init({
    environment: getEnvironment(),
    dsn: ENV_PUBLIC_SENTRY_DSN_KEY_DESKTOP,
    release: `${getWebsiteVersion()}-web`,
    integrations: [
      Sentry.browserTracingIntegration()
    ]
.
.
.
.
.
.
}

Steps to Reproduce

Our project has been using this sentry version"@sentry/nextjs" : "7.17.3" and now we are trying to update to the latest version which is as follows -

  "@sentry/nextjs": "7.118.0",
    "@sentry/webpack-plugin": "1.21.0",
    "next": "12.3.0"

We are using webpack to manage the release and upload the sourcemaps. We have tried almost every permutation to upload sourcemaps but somehow the sourcemaps are getting uploaded when I explicitly add sourcemaps as an option in the webpack's configuration like v8 configuration.
While going through the docs and code for the "7.118.0" version in @sentry/nextjs, @sentry/webpack-plugin I couldn't find any reference or usecase of sourcemaps key in the v7 version. However, it is being used in v8's SentryBuildOptions.
What could be the possible reason for this ?

I somewhere read that @sentry/webpack-plugin uses @sentry/cli to upload sourcemaps. Went through the code @sentry/webpack-plugin for v7 and v8 both and saw that it has @sentry/cli: "^1.77.1" as the dependency. Do you think "^" could be the reason that "@sentry/cli" might be getting updated to latest version in v7's @sentry/webpack-plugin also and thus expecting sourcemaps in the webpack config.

next.config.ts

const { withSentryConfig } = require('@sentry/nextjs');
const WEBSITE_VERSION = require('**/constants/webVersion');

const sentryWebpackPluginOptions = {
  sourcemaps: {
    assets: [ '.', '.next/static/chunks/' ],
    ignore: [ 'node_modules', 'build/' ]
  },
  // include: {
  //   paths: [ '.', '.next/static/chunks/' ],
  //   urlPrefix: `~/web-assets/***some_long_path*/_next/static/chunks/`
  // },
  urlPrefix: '~/web-assets/***some_long_path*/_next/static/chunks/',
  ext: [ 'map', 'js' ],
  ignore: [ 'node_modules', 'build/' ],
  org: 'web-sentry',
  project: 'web-prod',
  authToken: PRIVATE_SENTRY_AUTH_TOKEN,
  release: `${WEBSITE_VERSION}-web,
  silent: true
}
const DEFAULT_CONFIG = {
.
.
.
.
  swcMinify: true,
  assetPrefix: isProd ? publicPath : undefined,
  eslint: {
    // Warning: This allows production builds to successfully complete even if
    // your project has ESLint errors.
    ignoreDuringBuilds: true
  },
  compiler: {
    reactRemoveProperties: process.env.PWA_ENV === 'prod' ? { properties: [ 'data-test-id', 'dataTestId', 'inputDataTestId', 'errorDataTestId' ] } : {
      properties: [ '~^' ]
    }
  },
   //  Sentry SDK options
  sentry: {
    disableServerWebpackPlugin: true,    //By setting it to true the source map uploading for server build process will be disabled
    hideSourceMaps: true,                //This will make the source map invisible to the browser
    transpileClientSDK: true,           // support old browsers
    widenClientFileUpload: true,          // By setting it to "true", it uploads all of the files in static/chunks/ i.e. for even 3rd party libraries
    autoInstrumentServerFunctions: false //By setting it to false sentry does not auto wrap our data fetching functions such as getInitialProps (Automatic Static Optimization is preserved)
  },
  crossOrigin: 'anonymous',
  productionBrowserSourceMaps: true      //Enables browser source map generation during the production build
};

const NEXT_CONFIG = (isProdEnv || isNextEnv) ? withSentryConfig(DEFAULT_CONFIG, sentryWebpackPluginOptions) : DEFAULT_CONFIG;

module.exports = NEXT_CONFIG;

sentry.client.config.ts

import * as Sentry from '@sentry/nextjs';
const WEBSITE_VERSION = require('**/constants/webVersion');

 Sentry.init({
    environment: getEnvironment(),
    dsn: ENV_PUBLIC_SENTRY_DSN_KEY_DESKTOP,
    release: `${getWebsiteVersion()}-web`,
    integrations: [
      Sentry.browserTracingIntegration()
    ],
.
.
.
.
})

Image

Expected Result

Sourcemaps are not being uploaded.

Actual Result

Sourcemaps are not being uploaded only when provided sourcemaps option in webpack config.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    • Status

      Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions