Skip to content

Sentry starts sourcemap uploads before NextJS build is finished #13533

Closed
@jrandeniya

Description

@jrandeniya

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.27.0

Framework Version

Next 14.2.7, React 18.3.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

The @sentry/nextjs plugin seems to be upload the sourcemaps before the build finishes, therefore sourcemaps are missing:

[18:08:00.159] 
[18:08:01.168]   ▲ Next.js 14.2.7
[18:08:01.168]   - Experiments (use with caution):
[18:08:01.168]     · instrumentationHook
[18:08:01.168] 
[18:08:01.248]    Creating an optimized production build ...
[18:08:01.908] [@sentry/nextjs - Node.js] Debug: Release injection disabled via `release.inject` option. Will not inject release.
[18:08:01.968] [@sentry/nextjs - Node.js] Info: Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.
[18:08:38.834] [@sentry/nextjs - Node.js] Debug: Could not determine source map path for bundle: /vercel/path0/.next/server/chunks/4518.js - Did you turn on source map generation in your bundler?
[18:08:39.015] [@sentry/nextjs - Node.js] Debug: Could not determine source map path for bundle: /vercel/path0/.next/server/chunks/569.js - Did you turn on source map generation in your bundler?
[18:08:39.517] [@sentry/nextjs - Node.js] Debug: Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: /vercel/path0/.next/server/server-reference-manifest.js
[18:08:45.354] > Found 130 files
[18:08:45.404] > Analyzing 130 sources
[18:08:45.665] > Adding source map references
[18:08:52.111] > Bundled 130 files for upload
[18:08:52.111] > Bundle ID: 6a256cf8-196d-5e92-8edd-28d51ae661d3
[18:08:54.985] > Uploaded files to Sentry
[18:08:55.194] > File upload complete (processing pending on server)
[18:08:55.194] > Organization: XXX
[18:08:55.194] > Project: XXX
[18:08:55.194] > Release: 835964adfc06c9df63c3bb8f5aa2793f7161c652
[18:08:55.194] > Dist: None
[18:08:55.195] > Upload type: artifact bundle
[18:08:55.197] 
[18:08:55.197] Source Map Upload Report
[18:08:55.197]   Scripts
... (removed sourcemaps)
[18:08:55.198]     ~/386a00e4-d930-440f-932e-c4745618f3d3-54.js (sourcemap at 7603.js.map, debug id 386a00e4-d930-440f-932e-c4745618f3d3)
[18:08:55.198]     ~/388eb39e-5ace-444b-bad9-d862c4741100-47.js (no sourcemap ref, debug id 388eb39e-5ace-444b-bad9-d862c4741100)
[18:08:55.198]       **- warning: could not determine a source map reference (Could not auto-detect referenced sourcemap for ~/388eb39e-5ace-444b-bad9-d862c4741100-47.js)**
[18:08:55.215] [@sentry/nextjs - Node.js] Info: Successfully uploaded source maps to Sentry
[18:09:03.953] [@sentry/nextjs - Edge] Debug: Release injection disabled via `release.inject` option. Will not inject release.
[18:09:03.992] [@sentry/nextjs - Edge] Info: Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.
[18:09:07.999] [@sentry/nextjs - Edge] Debug: Could not determine source map path for bundle: /vercel/path0/.next/server/chunks/4518.js - Did you turn on source map generation in your bundler?
[18:09:08.063] [@sentry/nextjs - Edge] Debug: Could not determine source map path for bundle: /vercel/path0/.next/server/chunks/569.js - Did you turn on source map generation in your bundler?
[18:09:08.609] [@sentry/nextjs - Edge] Debug: Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: /vercel/path0/.next/server/interception-route-rewrite-manifest.js
[18:09:08.749] [@sentry/nextjs - Edge] Debug: Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: /vercel/path0/.next/server/server-reference-manifest.js

Then after heaps of upload logs as above (see timestamps) then Vercel prints:

[18:09:53.722]    Collecting page data ...
[18:10:00.048]    Generating static pages (0/21) ...
[18:10:06.422]    Generating static pages (5/21) 
[18:10:08.922]    Generating static pages (10/21) 
[18:10:12.882]    Generating static pages (15/21) 
[18:10:13.539]  ✓ Generating static pages (21/21)

Steps to Reproduce

Ran the npx @sentry/wizard@latest -i nextjs with the recommended configuration for each step and updated some basic config:

sentry.client.config.ts

// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";

Sentry.init({
  enabled: process.env.NODE_ENV !== "development",

  dsn: "https://....",

  // Add optional integrations for additional features
  integrations: [
    Sentry.replayIntegration(),
    Sentry.replayCanvasIntegration(),
  ],

  // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
  tracesSampleRate: 1,

  // Define how likely Replay events are sampled.
  // This sets the sample rate to be 10%. You may want this to be 100% while
  // in development and sample at a lower rate in production
  replaysSessionSampleRate: 0.1,

  // Define how likely Replay events are sampled when an error occurs.
  replaysOnErrorSampleRate: 1.0,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,
});

Expected Result

Sourcemaps to be uploaded after the NextJS build is complete.

Actual Result

Sourcemaps are uploaded while the build is still in progress and in Sentry, errors do not have sourcemaps:

Image
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions