Skip to content

TypeError: Cannot convert undefined or null to object #5501

Closed
@P4sca1

Description

@P4sca1

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/node

SDK Version

7.8.0

Framework Version

express 5.0.0-beta.1

Link to Sentry event

No response

Steps to Reproduce

After ugprading @sentry/integrations, @sentry/node, and @sentry/tracing from version 7.7.0 to 7.8.0, my application no longer starts up.

/**
 * Initializes Sentry.
 * @see {@link https://docs.sentry.io/platforms/node/}
 *
 * @param app - the Express.js app. Used to configure the Sentry-Express integration.
 */
export function initSentry(app: Express) {
	const env = process.env.SENTRY_ENV || process.env.NODE_ENV || 'development'
	const version = process.env.PACKAGE_VERSION

	Sentry.init({
		dsn: 'xxx',
		release: version ? `api@${version}` : undefined,
		environment: env,
		integrations: [
			new Dedupe(),
			new RewriteFrames({ root }),
			new Sentry.Integrations.Http({ breadcrumbs: true, tracing: true }),
			new Integrations.Express({ app }),
			new Integrations.Prisma({ client: prisma }),
		],
		beforeBreadcrumb: (breadcrumb) => {
			// Filter out writes to apollographql use reporting API, because they are not helpful for error tracing
			// and spam breadcrumbs.
			if (
				breadcrumb.type === 'http' &&
				typeof breadcrumb.data?.url === 'string' &&
				breadcrumb.data.url.includes('usage-reporting.api.apollographql.com')
			) {
				return null
			}

			return breadcrumb
		},
		tracesSampleRate: 0.25,
	})
}

Expected Result

It should continue to work as in version 7.7.0.

Actual Result

TypeError: Cannot convert undefined or null to object
    at Function.getPrototypeOf (<anonymous>)
    at instrumentRouter (omitted/node_modules/@sentry/tracing/cjs/integrations/node/express.js:195:28)
    at Express.setupOnce (omitted/node_modules/@sentry/tracing/cjs/integrations/node/express.js:48:5)
    at omitted/node_modules/@sentry/src/integration.ts:68:1
    at Array.forEach (<anonymous>)
    at Object.setupIntegrations (omitted/node_modules/@sentry/src/integration.ts:64:1)
    at NodeClient.setupIntegrations (omitted/node_modules/@sentry/src/baseclient.ts:258:1)
    at Hub.bindClient (omitted/node_modules/@sentry/src/hub.ts:123:1)
    at Object.initAndBind (omitted/node_modules/@sentry/src/sdk.ts:35:1)
    at Object.init (omitted/node_modules/@sentry/node/cjs/sdk.js:148:8)

Metadata

Metadata

Assignees

Labels

Package: nodeIssues related to the Sentry Node SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions