Skip to content

next build broken when wrapped with withSentryConfig #6782

Closed as not planned
Closed as not planned
@iscekic

Description

@iscekic

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.30.0

Framework Version

nextjs 13.1.2

Link to Sentry event

N/A

SDK Setup

// next.config.js
// some properties omitted to keep it short

/** @type {import('next').NextConfig} */
const moduleExports = {
  reactStrictMode: true,

  swcMinify: false,

  experimental: {
    fallbackNodePolyfills: false,
  },

  eslint: {
    ignoreDuringBuilds: true,
  },
  typescript: {
    ignoreBuildErrors: true,
  },

  distDir: "build",

  poweredByHeader: false,

  sentry: {
    hideSourceMaps: true,
    widenClientFileUpload: true,
    tunnelRoute: "/api/sentry-tunnel",
  },
};

const sentryWebpackPluginOptions = {
  silent: true,
  release: "some-generated-string",
  errorHandler: (err, invokeErr, compilation) => {
    compilation.warnings.push("Sentry CLI Plugin: " + err.message);
  },
};

const wrapper =
  process.env.ANALYZE === "1"
    ? require("@next/bundle-analyzer")({
        enabled: true,
      })
    : (arg) => arg;

module.exports = wrapper(
  withSentryConfig(moduleExports, sentryWebpackPluginOptions)
);

Steps to Reproduce

  1. yarn next build

If withSentryConfig is removed, the build passes.

Expected Result

Build succeeds, next start runs successfully

Actual Result

NODE_ENV=production CI=1 yarn build
                    
yarn run v1.22.19                                                                                                                                                                                                                                         
$ next build                                                                                                                                                                                                                                              
info  - Loaded env from /Users/igor/Projects/fireside-next-app/.env
warn  - You have enabled experimental feature (fallbackNodePolyfills) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

info  - Skipping validation of types
info  - Skipping linting
[@sentry/nextjs] You are using edge functions or middleware. Please note that Sentry does not yet support error monitoring for these features.
✨  Done in 56.93s.
NODE_ENV=production CI=1 yarn next start

yarn run v1.22.19                                                                                                                                                                                                                                         
$ /Users/igor/Projects/fireside-next-app/node_modules/.bin/next start                                                                                                                                                                                     
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /Users/igor/Projects/fireside-next-app/.env
warn  - You have enabled experimental feature (fallbackNodePolyfills) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

/Users/igor/Projects/fireside-next-app/build/BUILD_ID
Error: Could not find a production build in the '/Users/igor/Projects/fireside-next-app/build' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id
    at NextNodeServer.getBuildId (/Users/igor/Projects/fireside-next-app/node_modules/next/dist/server/next-server.js:173:23)
    at new Server (/Users/igor/Projects/fireside-next-app/node_modules/next/dist/server/base-server.js:58:29)
    at new NextNodeServer (/Users/igor/Projects/fireside-next-app/node_modules/next/dist/server/next-server.js:67:9)
    at NextServer.createServer (/Users/igor/Projects/fireside-next-app/node_modules/next/dist/server/next.js:143:16)
    at async /Users/igor/Projects/fireside-next-app/node_modules/next/dist/server/next.js:155:31
    at async NextServer.prepare (/Users/igor/Projects/fireside-next-app/node_modules/next/dist/server/next.js:130:24)
    at async /Users/igor/Projects/fireside-next-app/node_modules/next/dist/cli/next-start.js:118:9
error Command failed with exit code 1.                                                                                                                                                                                                                    
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions