Skip to content

[Self-hosted] Cannot read properties of undefined (reading 'getInitialProps') #8792

@KeithChou

Description

@KeithChou

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/browser

SDK Version

7.62.0

Framework Version

Next 13.4.11

Link to Sentry event

No response

SDK Setup

Sentry.init({
dsn: dsn,
// Replay may only be enabled for the client-side
enabled: true,
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 0.1

// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error

// ...

// Note: if you want to override the automatic release value, do not set a
// release value here - use the environment variable SENTRY_RELEASE, so
// that it will also get attached to your source maps
})

Steps to Reproduce

next.config.js file
this is the configuration content related to the sentry

/** @type {import('next').NextConfig} */
const withPlugins = require('next-compose-plugins')
const { createPlugin } = require('./build/next/createPlugin.ts')

const nextConfig = {
  // ...
  sentry: {
    hideSourceMaps: true,
    widenClientFileUpload: true
  },
  distDir: 'dist',
  // ..
}

module.exports = withPlugins(createPlugin(), nextConfig)

createPlugin file

const { withSentryConfig } = require('@sentry/nextjs')
const { configSentryWebpackPlugin } = require('../plugin/configSentryWebpackPlugin.ts')

exports.createPlugin = () => {
  const plugins = []
  plugins.push([withSentryConfig(configSentryWebpackPlugin())])

  return plugins
}

configSentryWebpackPlugin file

exports.configSentryWebpackPlugin = () => {
  return {
    org: process.env.SENTRY_ORG,
    url: process.env.SENTRY_URL,
    project: process.env.SENTRY_PROJECT,
    authToken: process.env.SENTRY_AUTH_TOKEN,
    silent: true, // Suppresses all logs,
    // For all available options, see:
    // https://github.com/getsentry/sentry-webpack-plugin#options.
  }
}

sentry.config.tsfile


Sentry.init({
  dsn: `dsn`,
  // Replay may only be enabled for the client-side
  enabled: true,
  // Set tracesSampleRate to 1.0 to capture 100%
  // of transactions for performance monitoring.
  // We recommend adjusting this value in production
  tracesSampleRate: 0.1

  // Capture Replay for 10% of all sessions,
  // plus for 100% of sessions with an error

  // ...

  // Note: if you want to override the automatic release value, do not set a
  // `release` value here - use the environment variable `SENTRY_RELEASE`, so
  // that it will also get attached to your source maps
})

sentry.client.config.ts, sentry.server.config.ts, sentry.edge.config.ts file

import './sentry.config'

.env: here is some sentry env

SENTRY_ORG = test
SENTRY_URL = url
SENTRY_PROJECT = project
SENTRY_AUTH_TOKEN = token

and when I run pnpm build, it will occur some error like this
image

I found there is a solution at #5978 and #5984. Unfortunately, it does not work for me. I don't know if is there any difference between saas and self-hoisted.

Expected Result

upload the sourcemap successfully.

Actual Result

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: browserIssues related to the Sentry Browser SDK

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions