Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js - separate build doesn't match files #14027

Closed
3 tasks done
leonardofaria opened this issue Oct 19, 2024 · 3 comments
Closed
3 tasks done

Next.js - separate build doesn't match files #14027

leonardofaria opened this issue Oct 19, 2024 · 3 comments
Labels
Package: browser Issues related to the Sentry Browser SDK

Comments

@leonardofaria
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

8.34.0

Framework Version

Next.js 14.2.3

Link to Sentry event

https://pistachio-x0.sentry.io/issues/6005511344/?project=4507376747937792

Reproduction Example/SDK Setup

Steps to Reproduce

Because of OOM issues, decided to split my build in 2 jobs: the one in Vercel deploys the application without uploading assets and one triggered in GHA will deploy the same version and create a release with the assets.

Things work almost perfectly: the jobs have the same build name but I can't find the right source file (check the issue link)

It is not clear why these messages are there:

  • Debug: Release injection disabled via release.inject option. Will not inject release.
    • I tried to track where this error is coming from and I didn't find it - any hints?
  • 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: /home/runner/work/REDACTED/REDACTED/.next/server/server-reference-manifest.js
    • Tried so many different things, including running fresh builds with cache, no luck

next.config.js

const buildForSentry = process.env.BUILD_FOR_SENTRY === 'true';

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    instrumentationHook: true,
    serverActions: {
      bodySizeLimit: '2mb', // Bump body size limit from 1 to 2 mb
    },
  },
  eslint: {
    ignoreDuringBuilds: true,
  },
  typescript: {
    ignoreBuildErrors: true,
  },
  productionBrowserSourceMaps: true,
  env: {
    NEXT_PUBLIC_SENTRY_RELEASE: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
  },
};

const { withSentryConfig } = require('@sentry/nextjs');

module.exports = withSentryConfig(nextConfig, {
  org: 'REDACTED',
  project: 'REDACTED',

  silent: false,

  debug: true,

  telemetry: false,

  widenClientFileUpload: buildForSentry,

  sourcemaps: {
    disable: !buildForSentry,
  },

  reactComponentAnnotation: {
    enabled: buildForSentry,
  },

  release: {
    name: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
    inject: buildForSentry,
  },

  disableLogger: true,

  automaticVercelMonitors: true,

  // Added for profiling
  async headers() {
    return [
      {
        source: '/:path*',
        headers: [
          {
            key: 'Document-Policy',
            value: 'js-profiling',
          },
        ],
      },
    ];
  },
});

Build output (GHA):

⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
  ▲ Next.js ***4.2.3
  - Environments: .env.local
  - Experiments (use with caution):
    · instrumentationHook
   Creating an optimized production build ...
[@sentry/nextjs - Node.js] Debug: Release injection disabled via `release.inject` option. Will not inject release.
[@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: /home/runner/work/REDACTED/REDACTED/.next/server/server-reference-manifest.js
> Found 244 files
> Analyzing 244 sources
> Adding source map references
> Bundled 244 files for upload
> Bundle ID: d4ebb***09-0***ab-52f3-ab89-b79a8220fddb
> Uploaded files to Sentry
> File upload complete (processing pending on server)
> Organization: REDACTED
> Project: javascript-nextjs
> Release: 74ad094
> Dist: None
> Upload type: artifact bundle
Source Map Upload Report
  Scripts
    ~/0365030c-f8ec-4***a4-ba3f-73528fe8c708-58.js (sourcemap at ***684.js.map, debug id 0365030c-f8ec-4***a4-ba3f-73528fe8c708)
    ~/07f6aad3-d422-4cfc-b996-f2b0f50***464e-77.js (sourcemap at 3982.js.map, debug id 07f6aad3-d422-4cfc-b996-f2b0f50***464e)
    ~/0cd54d74-cffe-45ac-9d79-538bc64b2d7c-***2.js (sourcemap at route.js.map, debug id 0cd54d74-cffe-45ac-9d79-538bc64b2d7c)
    ~/0e***08a39-f0ed-4792-a57f-e6e0***38b9a4c-3.js (sourcemap at page.js.map, debug id 0e***08a39-f0ed-4792-a
.... many files
bf5b-d0a76865d3***6)
[@sentry/nextjs - Node.js] Info: Successfully uploaded source maps to Sentry
[@sentry/nextjs - Edge] Debug: Release injection disabled via `release.inject` option. Will not inject release.
[@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: /home/runner/work/REDACTED/REDACTED/.next/server/interception-route-rewrite-manifest.js
[@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: /home/runner/work/REDACTED/REDACTED/.next/server/server-reference-manifest.js
> Found 250 files
> Analyzing 250 sources
> Adding source map references
> Bundled 250 files for upload
> Bundle ID: bdcf05ed-4826-5f59-a2dc-aa267e866bbd
> Uploaded files to Sentry
> File upload complete (processing pending on server)
> Organization: REDACTED
> Project: javascript-nextjs
> Release: 74ad094
> Dist: None
> Upload type: artifact bundle
Source Map Upload Report
  Scripts
    ~/0365030c-f8ec-4***a4-ba3f-73528fe8c708-58.js (sourcemap at ***684.js.map, debug id 0365030c-f8ec-4***a4-ba3f-73528fe8c708)
    ~/07f6aad3-d422-4cfc-b996-f2b0f50***464e-77.js (sourcemap at 3982.js.map, debug id 07f6aad3-d422-4cfc-b996-f2b0f50***464e)
...more files
~/fd7***72a3-c40a-45***c-97***f-f***3925dcc2d-86.js.map (debug id fd7***72a3-c40a-45***c-97***f-f***3925dcc2d)
    ~/fec08b***2-faee-4eba-a68a-4***379046fe***6-42.js.map (debug id fec08b***2-faee-4eba-a68a-4***379046fe***6)
    ~/fefb***3b5-2407-4d40-bf5b-d0a76865d3***6-***4.js.map (debug id fefb***3b5-2407-4d40-bf5b-d0a76865d3***6)
[@sentry/nextjs - Edge] Info: Successfully uploaded source maps to Sentry
[@sentry/nextjs - Client] Debug: Release injection disabled via `release.inject` option. Will not inject release.
[@sentry/nextjs - Client] Debug: Could not determine source map path for bundle: /home/runner/work/REDACTED/REDACTED/.next/static/chunks/app/admin/create-extract-prompt/[entityId]/page-b420db***726b0d3de.js - Did you turn on source map generation in your bundler?
[@sentry/nextjs - Client] Debug: Could not determine source map path for bundle: /home/runner/work/REDACTED/REDACTED/.next/static/chunks/app/admin/create-triage-prompt/page-7f948d688***343***eb.js - Did you turn on source map generation in your bundler?
[@sentry/nextjs - Client] Debug: Could not determine source map path for bundle: /home/runner/work/REDACTED/REDACTED/.next/static/chunks/app/storage/[fileUrl]/page-a278d445cc***29bb8.js - Did you turn on source map generation in your bundler?
> Found 249 files
> Analyzing 249 sources
> Adding source map references
> Bundled 249 files for upload
> Bundle ID: 627e6dd3-2207-5***4f-88fe-***b3685722878
> Uploaded files to Sentry
> File upload complete (processing pending on server)
> Organization: REDACTED
> Project: javascript-nextjs
> Release: 74ad094
> Dist: None
> Upload type: artifact bundle
Source Map Upload Report
  Scripts
    ~/00***8d043-00c5-4a70-b7***7-c634bb4***632f-2***.js (sourcemap at 3723546d-36ea59***6bd24***fcc.js.map, debug id 00***8d043-00c5-4a70-b7***7-c634bb4***632f)
    ~/0565d3***e-8bbd-49ec-a3***0-304***94***35e***0-44.js (sourcemap at 723***-a9a57***7c6a***78c5c.js.map, debug id 0565d3***e-8bbd-49ec-a3***0-304***94***35e***0)
    ~/0948003e-948e-46d8-8597-7c54e7ddd2e4-69.js (sourcemap at loading-d5ce60ef96ff57a9.js.map, debug id 0948003e-948e-46d8-8597-7c54e7ddd2e4)
    ~/099f2d52-fc37-4bda-9369-cec***b***c373c2-33.js (sourcemap at 5388-c62fe202d62bf86e.js.map, debug id 099f2d52-fc37-4bda-9369-cec***b***c373c2)
    ~/fafb448b-323***-4644-a***cf-e463b4732ef7-9.js.map (debug id fafb448b-323***-4644-a***cf-e463b4732ef7)
[@sentry/nextjs - Client] Info: Successfully uploaded source maps to Sentry
 ✓ Compiled successfully
   Skipping validation of types
   Skipping linting
   Collecting page data ...
   Generating static pages (0/37) ...
   Generating static pages (9/37) 
   Generating static pages (***8/37) 
   Generating static pages (27/37) 
 ✓ Generating static pages (37/37)
   Finalizing page optimization ...
   Collecting build traces ...

Expected Result

We were supposed to see the correct file as before duplicating the jobs. It is unclear in the docs how debug ID works and if it is possible to set that. I am already setting release name and I didn't need to use RewriteFrames in the previous setup so it is unclear why this is not working.

Thanks

Actual Result

Image


Image

@github-actions github-actions bot added the Package: browser Issues related to the Sentry Browser SDK label Oct 19, 2024
@lforst
Copy link
Member

lforst commented Oct 21, 2024

Hi, unfortunately, doing separate builds is not a supported use-case for sourcemap uploading. The sourcemaps and built files need to match exactly and this is not the case when rebuilding.

You may get a valid result when using a deterministic release value in withSentryConfig because that is usually the only non-deterministic part of your build, unless ofc you do something non-deterministic yourself.

@leonardofaria
Copy link
Author

Thanks for the response. Not sure if I understood your comment.

You may get a valid result when using a deterministic release value in withSentryConfig because that is usually the only non-deterministic part of your build, unless ofc you do something non-deterministic yourself.

I think this part is working fine. When I trigger an exception, it finds the release properly. The NEXT_PUBLIC_SENTRY_RELEASE var is the same in both GitHub and Vercel but still the issue can't be mapped properly. What is not clear to me:

  • 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: /home/runner/work/REDACTED/REDACTED/.next/server/server-reference-manifest.js
    • The output folder of a next project is .next and that folder was empty before the builder
  • Debug: Release injection disabled via release.inject option. Will not inject release.
    • My setup does have release.injected = true but it looks like my config is not being applied properly

@lforst
Copy link
Member

lforst commented Oct 22, 2024

In short: Doing separate builds is not supported. You need to build your application and upload your sourcemaps in one go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: browser Issues related to the Sentry Browser SDK
Projects
Archived in project
Development

No branches or pull requests

2 participants