getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.98k stars 1.57k forks source link

Uploading source maps breaks standalone nextjs build #13819

Closed ferdy-roz closed 1 month ago

ferdy-roz commented 1 month ago

Environment

SaaS (https://sentry.io/)

What are you trying to accomplish?

I ran the sentry wizard to set up our nextjs project. We are trying to deploy our app with sentry and upload source maps in CI.

How are you getting stuck?

We deploy via CodeBuild, and when we try to upload source maps we never get to the step of generating the standalone folder, set by setting output: "standalone" in next.config.mjs. I disabled sourcemaps in the sentry config and our build succeds/

Where in the product are you?

Issues - Source Maps

Link

No response

DSN

"https://8fe17b8c457f194e13b3f2c59119b9d6@o4507782612582400.ingest.us.sentry.io/4508016741187584"

Version

No response

getsantry[bot] commented 1 month ago

Assigning to @getsentry/support for routing ⏲️

chargome commented 1 month ago

Hey @ferdy-roz, could you paste your full next.config.mjs?

ferdy-roz commented 1 month ago
// @ts-check

import { withSentryConfig } from "@sentry/nextjs";
import createNextIntlPlugin from "next-intl/plugin";
import relayConfig from "./relay.config.json" with { type: "json" };

const withNextIntl = createNextIntlPlugin();

const config = withNextIntl({
  output: "standalone",
  compiler: {
    // @ts-ignore
    relay: relayConfig,
    removeConsole: process.env.NODE_ENV === "production",
  },
  experimental: {
    instrumentationHook: true,
  },
});

export default withSentryConfig(config, {
  // For all available options, see:
  // https://github.com/getsentry/sentry-webpack-plugin#options

  org: "tendrel",
  project: "console",
  sentryUrl: "https://sentry.io",

  // Only print logs for uploading source maps in CI
  silent: false,
  debug: true,

  // For all available options, see:
  // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

  // Upload a larger set of source maps for prettier stack traces (increases build time)
  widenClientFileUpload: true,

  // Automatically annotate React components to show their full name in breadcrumbs and session replay
  reactComponentAnnotation: {
    enabled: true,
  },

  // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
  // This can increase your server load as well as your hosting bill.
  // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
  // side errors will fail.
  tunnelRoute: "/monitoring",

  // Hides source maps from generated client bundles
  hideSourceMaps: true,

  // Automatically tree-shake Sentry logger statements to reduce bundle size
  disableLogger: true,
});
chargome commented 1 month ago

@ferdy-roz what error are you facing exactly? Please add debug: true to your config and check the logs

ferdy-roz commented 1 month ago

The final error we get is

ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 657cbd75-9081-4938-9b4d-b0acd7e92ab0::3crt0ifuo3q0zbd3t545ivaif: "/app/.next/standalone": not found
833 | upload resources required for deployment for console: build and push the image "console": build Dockerfile at /codebuild/output/src653262304/src/Dockerfile: building image: exit status 1
834 | Cloudformation stack and config files were not generated. Please check build logs to see if there was a manifest validation error.
835

but that's just the standalone directory not getting generated. Wasn't sure if something earlier in the process stopped us from getting there. I had tried setting debug: true but there weren't any more enlightening logs. I'll keep diving though.

chargome commented 1 month ago

If you can, please provide a small reproducible example!

ferdy-roz commented 1 month ago

I ended up adding a wait to our docker jobs and it somehow worked.. So maybe there was something weird on our end. It was hard to repro in a small way just because there was a lot of infra and everything, but it seems to be resolved!

Vi-lka commented 2 weeks ago

@ferdy-roz Can you provide a code example of how you solved this problem? I ran into the same problem and I still can't solve it.

Vi-lka commented 2 weeks ago

Adding webpack configuration to next config breaks output: "standalone". experimental: { webpackBuildWorker: true } fixed the problem