Skip to content

Sentry Spotlight sourcemaps work with Webpack but fail under Turbopack in Next.js (Next.js 16 + @sentry/nextjs) #1293

@amscu-dev

Description

@amscu-dev

To Reproduce

🔁 To Reproduce

  1. Start the application in development mode:
    next dev

### Current vs. Expected behavior

# 🐛 Sentry Spotlight sourcemaps fail under Turbopack in Next.js (Webpack works correctly)

---

## 📄 Description

When using `@sentry/nextjs` with Next.js 16, source maps and Spotlight integration work correctly in Webpack dev mode, but fail under Turbopack.

Even though Turbopack source maps are enabled via experimental flags, Sentry Spotlight does not resolve stack traces to original source files. Instead, it shows minified or chunked output.

---

## ⚙️ Next.js Configuration

### `next.config.ts`

```ts
import { withSentryConfig } from "@sentry/nextjs";
import type { NextConfig } from "next";
import bundleAnalyzer from "@next/bundle-analyzer";

const baseConfig: NextConfig = {
  reactStrictMode: false,

  async headers() {
    return [secHeaders];
  },

  experimental: {
    turbopackSourceMaps: true,
    turbopackInputSourceMaps: true,
  },
};

let nextConfig = baseConfig;

if (process.env.NEXT_PUBLIC_SENTRY_DISABLED !== "true") {
  nextConfig = withSentryConfig(nextConfig, {
    org: process.env.SENTRY_ORGANIZATION,
    project: process.env.SENTRY_PROJECT,
    authToken: process.env.SENTRY_AUTH_TOKEN,

    silent: !process.env.CI,
    widenClientFileUpload: true,

    // tunnelRoute intentionally disabled
    // tunnelRoute: "/monitoring",

    webpack: {
      reactComponentAnnotation: {
        enabled: true,
      },
      treeshake: {
        removeDebugLogging: true,
      },
    },

    telemetry: false,

    sourcemaps: {
      disable: false,
    },
  });
}

export default nextConfig;

🧪 Working Webpack Dev Configuration

When using Webpack, enabling devtool makes Sentry Spotlight work correctly:

webpack(config, { dev, isServer }) {
  if (dev && !isServer) {
    config.devtool = "source-map";
  }
  return config;
},

❌ Broken Behavior (Turbopack)

Example stack trace:

SentryExampleFrontendError
This error is raised on the frontend of the example page.
_next/static/chunks/0mo1j7r..js in onClick at line 150:35

  • No original file mapping
  • Only chunked/minified output shown
  • Debugging experience degraded

✅ Expected Behavior

Sentry Spotlight should resolve stack traces to original source files in both modes.


🧪 Webpack result (correct):

SentryExampleFrontendError
This error is raised on the frontend of the example page.
src/app/page.tsx (150:35)

Provide environment information

## 🧩 Environment

- Next.js: 16.x
- @sentry/nextjs: latest
- Node.js: 24+
- Bundlers:
  - Webpack (`next dev --webpack`)
  - Turbopack (`next dev`)
- Repro: local development

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions