Skip to content

Source maps not matching due to file renaming in @sentry/nextjs #13730

Closed as not planned
@annielinnik

Description

@annielinnik

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/nextjs

SDK Version

8.30.0

Framework Version

Next 14.2.6

Link to Sentry event

No response

Reproduction Example/SDK Setup

// sentry.client.config.ts
import * as Sentry from "@sentry/nextjs";

Sentry.init({
  dsn: '...',
  debug: true,
  enabled: true,
  environment: process.env.NEXT_PUBLIC_APP_ENV,
});

// sentry.server.config.ts , sentry.edge.config.ts
import * as Sentry from "@sentry/nextjs";

Sentry.init({
  dsn: '...',
  debug: true,
});

Steps to Reproduce

  1. Throw an error from sentry-example-page generated with npx @sentry/wizard@latest -i sourcemaps
  2. Source maps for this event not working:
  1. This is how the artifacts look like:

The way I see it: Sentry renames files, replacing their names with Debug ID and moving them to the root folder; then Sentry tries to find a file in _next/server/* and fails because there's no such file.

My next.config.js:

const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  output: "standalone",
  i18n: {
    locales: ["en"],
    defaultLocale: "en",
  },
  // fix 'fn' not found
  webpack(config, { webpack }) {
    config.resolve.fallback = {
      fs: false,
      dns: false,
      child_process: false,
    };
    config.plugins.push(
      new webpack.DefinePlugin({
        __SENTRY_DEBUG__: false,
        __SENTRY_TRACING__: false,
      })
    );
    return config;
  },

  async redirects() {
    return [];
  },

  async headers() {
    return [
      {
        // Apply these headers to all routes in your application.
        source: "/:any*",
        headers: [
          {
            key: "X-Frame-Options",
            value: "SAMEORIGIN",
          },
        ],
      },
    ];
  },

  experimental: {
    forceSwcTransforms: true,
    instrumentationHook: true,
  },
};

const nextConfigWithSentry = withSentryConfig(nextConfig, {
  authToken: process.env.SENTRY_AUTH_TOKEN,
  org: "sentry",
  project: "...",
  widenClientFileUpload: true,
  transpileClientSDK: true,
  disableLogger: false,
});

module.exports = nextConfigWithSentry;

Expected Result

Files uploaded to Sentry with their original names and paths. Source maps work.

Actual Result

Every file is renamed with format [debug_id].js and [debug_id].js.map and uploaded at root folder.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions